btamulis 7/25/2022 4:17:53 PM

SQL Cross Join RM30201 - sum Credits, Payments, etc.

Okay -

Script:

(select
CUSTNMBR, 
APTODCNM, 
CUSTNMBR,  
CASE WHEN APFRDCTY='9' then sum(APPTOAMT) else '0' end as Cash,
CASE WHEN APFRDCTY='8' then sum(APPTOAMT) else '0' end as Credits1,
CASE WHEN APFRDCTY='7' then sum(APPTOAMT) else '0' end as Credits2
from RM30201 A 
where APTODCTY='1' and APTODCNM like 'REF%' AND DATE1 >= '2017-01-01' and APTODCNM = 'REF371277'
GROUP BY CUSTNMBR, APTODCNM, APFRDCTY) BT

Returns: Multiple lines for a single document (with two payment types)

I would like the dataset to be a singular line regardless of multiple payments and payment types. I think I need a cross join RM30201 to itself.........having a hard time getting started. 

 

Thanks in advance, 

Bron

Version: All
Section: Dynamics GP, SQL Scripts


Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
3