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)

complex query in ax

(0) ShareShare
ReportReport
Posted on by

hi everyone. i'm relatively new to ax, i've searching on the web a way to create the next query but nothing seems to fit me needs.

select *

from (SELECT t1.field1, t1.field2, t2.field2, t2.field3, t2.field4, t2.field5, sum(t3.field2)
         from t1 join t2
         on t1.field1 = t2.field1 join t3
         on t1.field1 = t3.field1
         where condicions
         group by 1,2,3,4,5,6
         ) a

union
select *
from (select t1.field1,t1.field2,t1,field3,t1.field4,t1.field5,t1.field6, sum(t2.field2)
         from t1 join t2
         on t1.field1 = t2.field2
         where conditions
         group by 1,2,3,4,5,6
         ) b

is there a way to make this in ax 2009?

i've searched how to make union and joins but there seems to be a restriction to join sentences(exists, non exists) while using union.

any information is welcome.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Amir Nazim Profile Picture
    5,994 on at

    make two AOT views for individual selects and last query will be the union of those two AOT views

  • Community Member Profile Picture
    on at

    thanks for your reply amir, the last query can be putted in a grid without problem? or there is something that i should be aware of?

  • Suggested answer
    Amir Nazim Profile Picture
    5,994 on at

    for union query, column counts and sequence should be match.

    there is no problem in putting the query on form also, it is normal

    or you may create the 3rd view based on that union query and just drag the view as a datasource on form

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

  • Community Member Profile Picture
    on at

    thank you again, this solved my issue.

    another question, how can it sort the query based view according to a date?, i'm doing this through the AOT and i don't see an option to sort the union query. is it posibble?

  • Community Member Profile Picture
    on at

    hi amir i'm sorry if i bother you, i've been asked to choose some records from the final grid to update a field that's inside of, but since i'm working with views i cant directly do the changes to the db, i've thinking on dragging RecId and TableId data from the first views so i can do the query without error but it looks a bit dirty solution to me, mi question is. is there any other form to make this more "clean"?

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