Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9067

sales analysis is missing doctotal with down payment documents

$
0
0

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


Viewing all articles
Browse latest Browse all 9067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>