Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to Used Order By and Group By Clause in x++ Language when joins four table or more table......

Posted on by 875

Anyone cal tell me how to use Order By and Group By Clause in score table on marks .Field of score table is score1,socre2,score3  like

static void CXT_Joins(Args _args)
{
CXT_Student stud;
CXT_ContacInformation contact;
CXT_Location location;
CXT_Score score;
int k=0;
;
while select stud
join score
where stud.Cxt_Stud_Id==score.Cxt_Stud_Id
join location
where stud.Cxt_Stud_Id==location.Cxt_Stud_Id
join contact
where stud.Cxt_Stud_Id==contact.Cxt_Stud_Id
info("Hi Number has inserted");
info(strFmt("Id Is=%1---Score1 Is=%2---Score2 Is=%2----Score3 Is=%3---Location Is=%4---Mobile No Is=%5",stud.Cxt_Stud_Id,score.Score1,score.Score2,score.Score3,location.Location,contact.ContactPersonPhone));

}

 

 

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,588 Super User on at
    RE: How to Used Order By and Group By Clause in x++ Language when joins four table or more table......

    Vikash, please let me quote the documentation of select statement syntax (already linked above).

    KeywordDescriptionExample
    asc An option on the order by or group by clause. The sorting is ascending. (Sort is ascending by default.) select * from custTable
        order by Name asc;
    desc An option on the order by or group by clause. The sorting is descending. select * from custTable
        order by Name desc;

    Seriously, you won't become a developer if you don't learn how to use documentation.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Used Order By and Group By Clause in x++ Language when joins four table or more table......

    Hi Vikas,

    Can you please explain with example about how is your data in the tables and what results you want based on that?

  • Vikas_AX_Blogs Profile Picture
    Vikas_AX_Blogs 875 on at
    RE: How to Used Order By and Group By Clause in x++ Language when joins four table or more table......

    Hi Martin Sir

    i am beginner in AX and its only for practice. I want to arrange   Score in  Ascending and descending format  so how to apply order by clause in this x++ Code.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,588 Super User on at
    RE: How to Used Order By and Group By Clause in x++ Language when joins four table or more table......

    The syntax is documented, unsurprisingly, in Select Statement Syntax [AX 2012].

    You also have to realize that if you group records, you'll get values only those fields that are either grouped by or are aggregated (using aggregation functions such as sum() and maxOf()). You said that you want to group by Score1, Score2 and Score3, but you're also returning Cxt_Stud_Id, Location and ContactPersonPhone. You have to decide what to do with these fields.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans