I am trying to find the duplicate records across cross company, and it gives me an error on count keyword. Please help to identify it.
while select crosscompany : conCompanies AccountNum from vendTable group by vendTable.AccountNum Having count(vendTable.AccountNum) > 1 order by asc
Hi Harshal,
Have you tried the same with X++ code?
Thanks,
Girish S.
Hi Girish,
I tried this on X++ only. There its giving me the error on count - invalid token
Can you use only count(AccountNum) instead of count(vendTable.AccountNum).
Its giving me the same error Girish
Can you tell me what is the meaning of that line "Having count(vendTable.AccountNum) > 1"
If it throws error that means you are not allowed to use count function in that place.
I guess that without that line you will get the desired output.
I am looking for all the vendor accounts which have same value accross different legal entities.
Refer to the below thread.
https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/274321/how-to-find-duplicate-data-in-table?pifragment-96834=1
Hi, You can't use count in where condition. There is an alternative which I think we have discussed before, please check this article.
allaboutax.blogspot.com/.../duplicate-records-in-dynamics-365.html
while select crosscompany AccountNum, count(RecId) from vendTable order by vendTable.AccountNum asc group by vendTable.AccountNum { if (vendTable.RecId) > 1) { //Duplicate record } }
For that case you can simply give a SQL query in SSMS which saves time. Any issue there?
Hey Mohit,
This worked. Thanks again
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 1,850
André Arnaud de Cal... 795 Super User 2025 Season 2
Sohaib Cheema 519 User Group Leader