Hi,
I have a query which gives me result of sales in EUR , USD and other.
Problem I have is that when the invoice is based on a down payment the total is zero (0) in the query result.
How can I solve this??
And is it possbile to add an grand total for each column at the bottom???
Below is the query:
SELECT T0.[CardCode], T0.[CardName],
(
case when t1.DocCur = 'EUR' then sum(T1.[DocTotal]) end) as 'EUR',
(
case when t1.DocCur = 'USD' then sum(T1.[DocTotalFC]) end) as 'USD',
(
Case when t1.DocCur < 'USD' AND t1.DocCur <> 'EUR' then sum(T1.[DocTotalFC]) end ) as 'Other'
FROM OCRD T0
INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
WHERE T1.[DocDate] >= '[%0]' and T1.[DocDate] <= '[%1]'
GROUP BY T0.[CardCode], T0.[CardName], T1.[DocCur]
UNION
SELECT T0.[CardCode], T0.[CardName],
(
case when t1.DocCur = 'EUR' then sum(-T1.[DocTotal]) end) as 'EUR',
(
case when t1.DocCur = 'USD' then sum(-T1.[DocTotalFC]) end) as 'USD',
(
Case when t1.DocCur <> 'USD' AND t1.DocCur <> 'EUR' then sum(-T1.[DocTotalFC]) end ) as 'Other'
FROM OCRD T0
INNER JOIN ORIN T1 ON T0.CardCode = T1.CardCode
WHERE T1.[DocDate] >= '[%0]' and T1.[DocDate] <= '[%1]'
GROUP BY T0.[CardCode], T0.[CardName], T1.[DocCur]
ORDER BY T0.CardCode