N
Nuno Gomes
Hello,
I use the query:
SELECT MONTH(P.DOC_DATE) MONTH_, COUNT(*) CUSTOMERS_ATL,
(
SELECT SUM(STAT_CAISSE_J.STAT_VALEUR9)
FROM STAT_CAISSE_J
WHERE (CONVERT(CHAR, STAT_CAISSE_J.STAT_DATE, 112) >= '20090101'
AND CONVERT(CHAR, STAT_CAISSE_J.STAT_DATE, 112) <='20091231')
AND STAT_CAISSE_J.STAT_TYPE=1
)-COUNT(*) CUSTUMERS_VND
FROM ATL_DOCUMENT P
WHERE (P.DOC_TYPE=14 OR P.DOC_TYPE=15)
AND (CONVERT(CHAR, P.DOC_DATE, 112) >= '20090101'
AND CONVERT(CHAR, P.DOC_DATE, 112) <='20091231')
GROUP BY MONTH(P.DOC_DATE)
And the result is:
MONTH_ CUSTOMERS_ATL CUSTUMERS_VND
----------- ------------- -----------------------------------------------------
7 77 417.0
8 4 490.0
12 2 492.0
The month_ and customers_atl are ok.
But the customer_vnd is not ok because the main query have a GROUP BY clause
and the subquery don't made the group by.
How can this could be made?
Thanks,
Nuno
I use the query:
SELECT MONTH(P.DOC_DATE) MONTH_, COUNT(*) CUSTOMERS_ATL,
(
SELECT SUM(STAT_CAISSE_J.STAT_VALEUR9)
FROM STAT_CAISSE_J
WHERE (CONVERT(CHAR, STAT_CAISSE_J.STAT_DATE, 112) >= '20090101'
AND CONVERT(CHAR, STAT_CAISSE_J.STAT_DATE, 112) <='20091231')
AND STAT_CAISSE_J.STAT_TYPE=1
)-COUNT(*) CUSTUMERS_VND
FROM ATL_DOCUMENT P
WHERE (P.DOC_TYPE=14 OR P.DOC_TYPE=15)
AND (CONVERT(CHAR, P.DOC_DATE, 112) >= '20090101'
AND CONVERT(CHAR, P.DOC_DATE, 112) <='20091231')
GROUP BY MONTH(P.DOC_DATE)
And the result is:
MONTH_ CUSTOMERS_ATL CUSTUMERS_VND
----------- ------------- -----------------------------------------------------
7 77 417.0
8 4 490.0
12 2 492.0
The month_ and customers_atl are ok.
But the customer_vnd is not ok because the main query have a GROUP BY clause
and the subquery don't made the group by.
How can this could be made?
Thanks,
Nuno