RM Transactions with Distributions

IF object_id(N'ddv_RMTransactionsWithDists', 'V') IS NOT NULL
    DROP VIEW ddv_RMTransactionsWithDists
GO
     
CREATE VIEW ddv_RMTransactionsWithDists
     
AS
   
  
             SELECT rt.*, dist.CRDTAMNT, dist.DEBITAMT, dist.DSTINDX, dist.DISTTYPE
    FROM (
        SELECT rt.DOCNUMBR, rt.RMDTYPAL, rt.ORTRXAMT, rt.CURTRXAM, rt.CUSTNMBR, 'Open' as source FROM rm20101 rt UNION all
        SELECT rt.DOCNUMBR, rt.RMDTYPAL, rt.ORTRXAMT, rt.CURTRXAM, rt.CUSTNMBR, 'Hist' as source FROM rm30101 rt
    ) rt
    LEFT JOIN rm30301 dist ON dist.DOCNUMBR = rt.DOCNUMBR AND dist.RMDTYPAL = rt.RMDTYPAL
    ORDER BY rt.DOCNUMBR 
  
GO
  
grant SELECT on ddv_RMTransactionsWithDists to PUBLIC

 

 

SELECT rt.*, dist.CRDTAMNT, dist.DEBITAMT, dist.DSTINDX, dist.DISTTYPE
    FROM (
        SELECT rt.DOCNUMBR, rt.RMDTYPAL, rt.ORTRXAMT, rt.CURTRXAM, rt.CUSTNMBR, 'Open' as source FROM rm20101 rt UNION all
        SELECT rt.DOCNUMBR, rt.RMDTYPAL, rt.ORTRXAMT, rt.CURTRXAM, rt.CUSTNMBR, 'Hist' as source FROM rm30101 rt
    ) rt
    LEFT JOIN rm30301 dist ON dist.DOCNUMBR = rt.DOCNUMBR AND dist.RMDTYPAL = rt.RMDTYPAL
    ORDER BY rt.DOCNUMBR

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences