Skip to main content

Notifications

Microsoft Dynamics AX (Archived)
Answered

X++ select group by date

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

It seems a stupid question but I tried multiple combination and failed.

In table A, I have thousands of records and I want to get all the different dates in this record.

In SQL, I know I can do it simply by

select date from TableA group by date

But now for X++ in AX

I tried

while select   A group by A.Date
{

}

without success. In MS doc, the examples are for number or counting no dates. I don't quite understand how to achieve my requirement.  Any help is grateful! Thanks!

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ select group by date

    Thanks, the problem is solved.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ select group by date

    Yes, you are right. I made a mistake.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: X++ select group by date

    Do you have any records in that company ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ select group by date

    Hi Martin, my result is no result in return in my selection

  • Martin Dráb Profile Picture
    Martin Dráb 230,836 Most Valuable Professional on at
    RE: X++ select group by date

    It would help if you actually explained your problem. Saying "without success" doesn't tell us too much.

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: AX X++ select group by date

    https://msdn.microsoft.com/en-us/library/aa656402.aspx

    group by

    Instructs the database to group selected records by fields.

    CustTable custTable;

    ;

    while select sum(CreditMax) from custTable

        group by CustGroup

    {

        print custTable.CustGroup, " ",custTable.CreditMax;

    }

    You could do a count(RecId) to see how many records you have for the specific date instead of the sum() aggregate function in the example, and use the date for your grouping.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans