Wednesday, March 7, 2018

Dynamics GP - SQL View Last Exchange Rate for each Currency

SELECT     DYNAMICS.dbo.MC00100.EXGTBLID, DYNAMICS.dbo.MC00100.CURNCYID, DYNAMICS.dbo.MC00100.EXCHDATE, DYNAMICS.dbo.MC00100.TIME1, DYNAMICS.dbo.MC00100.XCHGRATE, DYNAMICS.dbo.MC00100.EXPNDATE,
                  DYNAMICS.dbo.MC00100.DEX_ROW_ID
FROM        DYNAMICS.dbo.MC00100 INNER JOIN
                      (SELECT     CURNCYID, MAX(DEX_ROW_ID) AS ExchDR
                       FROM        DYNAMICS.dbo.MC00100 AS MC00100_1
                       WHERE     (GETDATE() BETWEEN EXCHDATE AND EXPNDATE)
                       GROUP BY CURNCYID) AS ExchDr ON DYNAMICS.dbo.MC00100.DEX_ROW_ID = ExchDr.ExchDR
WHERE     (GETDATE() BETWEEN DYNAMICS.dbo.MC00100.EXCHDATE AND DYNAMICS.dbo.MC00100.EXPNDATE)

No comments:

Post a Comment