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 AX (Archived)

Union in while select

(0) ShareShare
ReportReport
Posted on by 867

How to apply union in while select query.Here is sql query

Select Column1 from Table1

Union

Select Column1 from Table2

and make sure there is no duplicate rows

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    You can't do that in the select statement, but you can define an union AOT query. See more in How to: Combine Data Sources in a Union Query.

    Unfortunately AX doesn't support DISTINCT SQL keyword (what a shame!), so you'll have to either construct your query not to return duplicate rows or handle them in the application layer.

  • dolee Profile Picture
    11,279 on at

    Martin is right. In addition, if you are only selecting a small number of fields, you can use group by in AOT query to achieve result similar to a DISTINCT. (Assume there are applicable aggregates you can apply on those fields)

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans