web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

SQL Query - Duplicate Rows (Can't find unique link between table RM10101 and RM20101)

(0) ShareShare
ReportReport
Posted on by 766

Here is a Query I pulled together. Overall goal is to export ALL Open transactions to import into a new company.

I see the issue is with the below from(I can't seem to find the right link to omit duplicate rows).

  RIGHT OUTER JOIN RM10101 as dis ON  dis.DOCNUMBR = inv.DOCNUMBR

Is there another table I should be using?

-----------------------------------------------------------------------------------------------------------------------

SELECT
    INV.CUSTNMBR as "Customer ID",
    v.custname as "Customer Name",
    CAST(INV.DOCDATE as DATE) as "DOC DATE",
    INV.SLPRSNID as "SLS Code",
    INV.SLSTERCD as "Terr Code",
    DIS.DistRef as "Distrib Ref",
    INV.DOCNUMBR as "DOC Number",
    DIS.DEBITAMT as "Debit Amt",
    DIS.CRDTAMNT as "Credit Amount",
    GL.ACTNUMST as "Account Num",
    DIS.DISTTYPE as "Distribution Type",
    INV.CSPORNBR as "P.O. Number",
    INV.TRXDSCRN as "Description",
    INV.RMDTYPal as "Transaction Type",
    INV.ORTRXAMT as "OMIT - Orig Amt",
    INV.CURTRXAM as "Replace With - Current Amt"  --Separate Debit and Credits accordingly and confirm amount matches ARTB.
    
FROM RM20101 as INV --Open Transactions
    RIGHT OUTER JOIN RM10101 as dis ON  dis.DOCNUMBR = inv.DOCNUMBR
    RIGHT OUTER JOIN gl00105 as gl ON gl.ACTINDX = dis.DSTINDX
    JOIN RM00101 as v ON v.CUSTNMBR = inv.CUSTNMBR    
WHERE INV.CURTRXAM > '0' and inv.CUSTNMBR = 'ILDCFS427' and inv.docnumbr = 'L5661704-DEC16RB'
ORDER BY inv.CUSTNMBR, inv.DOCDATE, INV.DOCNUMBR, inv.TRXDSCRN

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Rows are not duplicating, you are having distribution amounts so that's why it's showing all the lines.

  • Verified answer
    Napolo Profile Picture
    766 on at

    I got it.

    JOIN RM10101 as dis ON  dis.DOCNUMBR = inv.DOCNUMBR and dis.RMDTYPAL = inv.RMDTYPAL

    I was missing the additional unique identifier. It now omits the duplicates.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans