Wednesday, December 28, 2016

Dynamics GP - SQL Views - All AR Distribution Accounts that have been hit by AR transactions

SELECT     YEAR(AllRM.POSTEDDT) AS PostYr, MONTH(AllRM.POSTEDDT) AS PostMth, GL00105.ACTNUMST, GL00100.ACTDESCR, SUM(AllRM.DEBITAMT) AS Deb,
                      SUM(AllRM.CRDTAMNT) AS Cred, AllRM.DISTTYPE
FROM         GL00105 INNER JOIN
                      GL00100 ON GL00105.ACTINDX = GL00100.ACTINDX INNER JOIN
                          (SELECT     POSTEDDT, DSTINDX, DEBITAMT, CRDTAMNT, DISTTYPE
                            FROM          (SELECT     POSTEDDT, DSTINDX, DEBITAMT, CRDTAMNT, DISTTYPE
                                                    FROM          RM10101
                                                    UNION
                                                    SELECT     POSTEDDT, DSTINDX, DEBITAMT, CRDTAMNT, DISTTYPE
                                                    FROM         RM30301) AS derivedtbl_1) AS AllRM ON GL00105.ACTINDX = AllRM.DSTINDX
GROUP BY YEAR(AllRM.POSTEDDT), GL00105.ACTNUMST, GL00100.ACTDESCR, MONTH(AllRM.POSTEDDT), AllRM.DISTTYPE
ORDER BY YEAR(AllRM.POSTEDDT), MONTH(AllRM.POSTEDDT), GL00105.ACTNUMST

No comments:

Post a Comment