Мы используем SAP HANA 1.0 SPS12.
Когда я запускаю запрос ниже -
select count(*)
from ( SELECT A.MATNR ARTICLE,
A.WERKS SITE,
ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.DMBTR) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.DMBTR) END),0)))) DUMP_VALUE,
ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.MENGE) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.MENGE) END),0)))) DUMP_QTY
FROM MSEG A
INNER JOIN S_SITE_MASTER B ON A.WERKS=B.STORE_NO
INNER JOIN S_PRODUCT_MASTER C ON A.MATNR=C.MATERIAL
WHERE A.BUDAT_MKPF >= ADD_MONTHS(NEXT_DAY(LAST_DAY(ADD_DAYS(CURRENT_DATE,-1))),-1)
AND A.BUDAT_MKPF <= ADD_DAYS(CURRENT_DATE,-1)
AND A.BWART IN ('551','552','951','952')
AND C.LEVEL2 = 10
AND B.FORMAT_CD IN ('1')
GROUP BY A.MATNR,
A.WERKS
);
Количество выводов - 129790
ЕСЛИ я просто поменяю пункт AND B.FORMAT_CD IN ('1')
на AND B.FORMAT_CD IN (1)
, как показано ниже -
select count(*)
from (SELECT A.MATNR ARTICLE,
A.WERKS SITE,
ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.DMBTR) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.DMBTR) END),0)))) DUMP_VALUE,
ROUND((SUM(COALESCE((CASE WHEN A.BWART IN('551','951') THEN(A.MENGE) END),0))-SUM(COALESCE((CASE WHEN A.BWART IN('552','952') THEN(A.MENGE) END),0)))) DUMP_QTY
FROM MSEG A
INNER JOIN S_SITE_MASTER B ON A.WERKS=B.STORE_NO
INNER JOIN S_PRODUCT_MASTER C ON A.MATNR=C.MATERIAL
WHERE A.BUDAT_MKPF >= ADD_MONTHS(NEXT_DAY(LAST_DAY(ADD_DAYS(CURRENT_DATE,-1))),-1)
AND A.BUDAT_MKPF <= ADD_DAYS(CURRENT_DATE,-1)
AND A.BWART IN ('551','552','951','952')
AND C.LEVEL2 = 10
AND B.FORMAT_CD IN (1)
GROUP BY A.MATNR,
A.WERKS
);
Количество выходов - 29403 (это правильный счет)
Тип данных B.FORMAT_CD - NVARCHAR (3).
Как счет ведет себя по-другому?