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

Re: consulta de saldos vencidos

$
0
0

gracias ya lo realice con un case anilado

 

SELECT T0.CardCode AS 'supplier code',

T0.CardName AS 'supplier Name',

CASE when T0.DocType = 'S' AND T0.DocCur = 'USD' AND T0.CardCode = T0.CardCode then SUM(T0.DocTotalFC) - SUM(T0.PaidSys) else

CASE When T0.DocType = 'S' AND T0.DocCur = 'MXN' AND T0.CardCode = T0.CardCode then SUM(T0.DocTotal) - SUM(T0.PaidSys) else 0 end end AS 'servicio',

CASE when T0.DocType = 'I' AND T0.DocCur = 'USD' AND T0.CardCode = T0.CardCode then SUM(T0.DocTotalFC) - SUM(T0.PaidSys) else

CASE When T0.DocType = 'I' AND T0.DocCur = 'MXN' AND T0.CardCode = T0.CardCode then SUM(T0.DocTotal) - SUM(T0.PaidSys) else 0 end end AS 'Articulos',

T0.DocCur

FROM OPCH T0

WHERE DATEDIFF (DD, T0.DocDueDate, GETDATE( )) BETWEEN -7 AND 365

AND T0.DocStatus = 'O' AND T0.SERIES = 10 AND T0.CANCELED = 'N'

GROUP BY T0.CardCode,T0.CardName,T0.DocType,T0.DocCur

ORDER BY T0.CardCode,T0.CardName,T0.DocType

FOR BROWSE


Viewing all articles
Browse latest Browse all 2878

Trending Articles



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