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

Re: Query shows invoice # twice because I have two lines but shows balance after payment with the total on each line and not the individual amount on each line.

$
0
0

Hi,

 

Try this first:

 

Select T4.[SlpName] as 'Sales Employee', T0.cardname as 'Customer',T0.Docdate as 'Month of Service', T0.docnum as 'Invoice Number', T0.[U_AIS_DVIInvName] as 'SF Invoice Name', T0.Taxdate as 'Date Sent',isnull(T0.U_AIS_DVISFSO,T3.U_AIS_DVISFSO) as 'SO#',T0.NumAtCard as 'PO#',

isnull(T0.U_AIS_DVIAdvNm,T3.U_AIS_DVIAdvNm) as 'Advertiser', isnull(T0.U_AIS_DVIOpptyNm,T3.U_AIS_DVIOpptyNm) as 'Campaign',Max(T1.Dscription),Sum(T1.Quantity) as 'Impressions',Sum(T1.linetotal) as 'Total',Sum(T1.[LineVat]) as 'Vat Tax',

T0.doctotal as 'Invoice Total',(T0.Doctotal-T0.Paidsum) as 'Balance after payment',T0.docstatus, 'Invoice' AS TransactionType, T0.CurSource, T0.DocCur, T0.[Comments]

from OINV T0

left outer join INV1 T1 on T0.docentry = T1.docentry

left outer join RDR1 T2 on T1.Baseentry = T2.docentry and T1.baseline = T2.linenum

left outer join ORDR T3 on T2.docentry = T3.docentry

left outer join OSLP T4 ON T0.Slpcode= T4.Slpcode

 

Where T0.[DocDate] >= '[%1]'

AND T0.[DocDate]   <= '[%2]'

Group By  T4.[SlpName]',T0.cardname,T0.Docdate, T0.docnum,T0.[U_AIS_DVIInvName], T0.Taxdate,T0.U_AIS_DVISFSO,T3.U_AIS_DVISFSO,T0.NumAtCard,T0.U_AIS_DVIAdvNm,T3.U_AIS_DVIAdvNm, T0.U_AIS_DVIOpptyNm,T3.U_AIS_DVIOpptyNm,T0.doctotal,T0.Paidsum,T0.docstatus, T0.CurSource, T0.DocCur, T0.[Comments]


Viewing all articles
Browse latest Browse all 9063

Trending Articles