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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

check duplicate record fields from 2 table using join and while select statement

(0) ShareShare
ReportReport
Posted on by 220

HI everyone,

I have  a project that I am stuck with, I need to retreive data from 2 tables as follows:

tableA has filed commisson_number also tableB has field commisson_number I am able to join these two tables on puchId and retreive 16 records.  Now once this is done I need to check for duplicates from those 16 records any ideas how to do this?  I have the following code so far:

I need to check how many duplicate commission number on tableB per purchId as purchId is the commone field between the 2 tables.

 

static void Job11(Args _args)
{
    TableA              tableA;
    TableB              tableB;
    PurchStatus             ps;
   
   

    ;


    while select tableA where tableA.CommissionNum != ' ' && tableA.PurchStatus!=PurchStatus::Invoiced
    join tableB where tableB.PurchId == tableA.PurchId && tableB.CommissionNum > '0'


    {



        info(strfmt("data from tableA: %1", tableA.CommissionNum));


        ps = TableA.PurchStatus;

        info(strfmt("purch status '%1'",enum2str(ps)));

       



    }


}

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    Re: check duplicate record fields from 2 table using join and while select statement

    You have several options. You can use your while select and save information about number of CommissionNum to a Map or so. I would probably rewrite the while select to a Query instance, add Group By and count() and check for records with count() > 1.

  • Charles P Profile Picture
    220 on at
    Re: check duplicate record fields from 2 table using join and while select statement

    sounds good can you give me an example to work with?  thanks

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans