Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Select that returns a maxof and sum of the same field.

Posted on by Microsoft Employee

I am querying thru the business connector and I need to get the maxof and sum of the same field.  Since there is no way to alias in AX is this possible?

Here is my query

Select KEY1, maxof(REALCONSUMP), sum(REALCONSUMP) FROM %1 GROUP BY KEY1,PRODID WHERE PRODID == '{0}'

If I use .get_Field("REALCONSUMP") I get the maxof but I dont know how to get the maxof.

Thanks

Brian

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Select that returns a maxof and sum of the same field.

    LOL!  Good question.  I got so caught up in the aggregates I didn't notice I still had that in the group by.  Thanks for the answer.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: Select that returns a maxof and sum of the same field.

    No, it's not possible. AX returns a table buffer; its fields are defined at design time and not at runtime. There is just one RealConsump field.

    You need a different approach, such as two queries.

    By the way, what's the point of grouping by ProdId if the query is filtered to return data just for a single ProdId?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans