Quantcast
Channel: SCN: Message List - Reporting and Printing
Viewing all articles
Browse latest Browse all 2719

Aging Report Group By

$
0
0

Hello,

 

Is it possible to group all of the results in this query by BP Code?  I have applied the Group BY but it is still showing each line for each BP, rather a total cumulative value for each BP.  ANy ideas on how to get one result for each BP?

 

Thanks and appreciate the insight!

 

Here is the query I am using:

 

select T1.cardcode 'Bp Code',T1.cardname 'Name',T1.Address, T1.ZipCode, T1.Phone1, T1.e_mail, getdate() AS 'Report Date', sysdeb 'Debit Amount',syscred 'Credit Amount', (sysdeb - syscred) as 'Balance Due',

case T0.transtype

when '13' then 'INV'

when '14' then 'AR CN'

when '24' then 'INCOMING'

else 'Other'

end 'Type',

Ref1,

fccurrency 'BP Currency',

CONVERT(VARCHAR(10), refdate, 103) 'Posting Date',

CONVERT(VARCHAR(10), duedate, 103) 'Due Date',

CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,

CASE

when (DATEDIFF(dd,refdate,current_timestamp))+1 < 31

then

case

when syscred <> 0 then -syscred

else sysdeb

end

end "0-30 days",

case when ((datediff(dd,refdate,current_timestamp))+1 > 30

and (datediff(dd,refdate,current_timestamp))+1< 61)

then

case

when syscred <> 0 then -syscred

else sysdeb

end

end "31 to 60 days",

case when ((datediff(dd,refdate,current_timestamp))+1 > 60

and (datediff(dd,refdate,current_timestamp))+1< 91)

then

case

when syscred <> 0 then -syscred

else sysdeb

end

end "61 to 90 days",

CASE

when (DATEDIFF(dd,refdate,current_timestamp))+1 > 90

then

case

when syscred= 0 then sysdeb

when sysdeb= 0 then -syscred

end

end "90 + days"

from dbo.JDT1 T0

INNER JOIN dbo.OCRD T1 ON T0.shortname = T1.cardcode and T1.cardtype = 'c'

where T0.intrnmatch = '0' and T0.BALDUEDEB != T0.BALDUECRED AND T1.GroupCode = '103'

group by

T1.cardcode,T1.cardname,T1.Address, T1.ZipCode, T1.Phone1, T1.e_mail, T0.sysdeb, T0.syscred, T0.transtype, T0.Ref1, T0.FCCurrency, T0.Refdate, T0.duedate, T0.taxdate

ORDER BY T1.Cardcode, T0.taxdate

 

If I select to group By just T1.Cardcode I get the error: is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.  I do believe that is telling me that there are 2 different T1.cardcodes in the query and it does not know which one to use.  I'm not sure how to separate them out


Viewing all articles
Browse latest Browse all 2719

Trending Articles



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