Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

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

Posted on by 750

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

  • Verified answer
    Napolo Profile Picture
    Napolo 750 on at
    RE: SQL Query - Duplicate Rows (Can't find unique link between table RM10101 and RM20101)

    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.

  • Suggested answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: SQL Query - Duplicate Rows (Can't find unique link between table RM10101 and RM20101)

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans