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)

Advantage of Union query.

(0) ShareShare
ReportReport
Posted on by 30

Dear All,

Can you please give me an example of Union query in Dynamics AX 2012 R3.

what is the advantage of Union query?

How to write X++ code with using Union query.

Please give me an example.

Please give me more shed on this.

Thanks!

Arpan

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    you can not use union in x++ but you can use it in Query from AOT

    union is useful to combine multiple datasources

    msdn.microsoft.com/.../cc605991.aspx

  • @rp@n Profile Picture
    30 on at

    Thanks Hakim

    Can you please let me know when we use exactly Union query?

    Please give me more shed on this.

    Thanks!

    Arpan

  • Verified answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    in general, if you write two complex query in sql , you can union this quires.

    so we use union based on your requirements

    if it is difficult to return your data by one query in sql . you can create two quires and use union

    as the same in AOT you can create multiple datasources and use union

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Union query is useful if we want to have several datasources of same table or type on the query.

    Refer this link:

    (Union queries)

    community.dynamics.com/.../union-queries

  • @rp@n Profile Picture
    30 on at

    Thanks Chaitanya

    Sorry not understand "if we want to have several datasources of same table or type on the query".

    Please give me an example.

    Please give me more shed on this.

    Thanks!

    Arpan

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    If you check the example in the suggested link, it has two datasources of type inventtable at different stages with different ranges. It has two options with Union and UnionAll.

    where Union removes duplicated records and UnionAll keeps duplicated records.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    please go on w3 schools for basics. that could be best source as start for these concepts

    www.w3schools.com/.../sql_union.asp

    once you will have knowledge of UNION and UnionAll, I can see next question should be as following

    Difference between Union and Full Outer join. You can search and read this as well.

  • Verified answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    yes, Chaitanya is correct

    we can use it to remove duplication

  • @rp@n Profile Picture
    30 on at

    Thanks Chaitanya and Hakim

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