web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Alternative for the SQL Having keyword in X++ sql statements.

(0) ShareShare
ReportReport
Posted on by

Hello All,

I have the below SQL query currently working in AX 2012:

while select sum(amount) from tempTable

group by DataAreaID



but I would like to add something similar to a sql having clause, such as below:

while select sum(amount) from TempTable

group by dataAreaID

having sum <> 0

 


But it seem that the having keyword is not supported by X++ sql.

Does anyone have a suggestion how I can implement that select logic? Or any documentation on alternatives to the having keyword? It would be a huge help.

Thank you,

Phil

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Alternative for the SQL Having keyword in X++ sql statements.

    Sorry, the second select statement should have read:

    while select sum(amount) from TempTable

    group by dataAreaID

    having sum != 0

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Alternative for the SQL Having keyword in X++ sql statements.

    Actually I think I figured this out.

    If I just add a if(TempTable.Amount != 0) statement, I should be able to get the code to work how I want to.

    Thanks everyone who read this!

  • Verified answer
    Martin Dráb Profile Picture
    236,394 Most Valuable Professional on at
    RE: Alternative for the SQL Having keyword in X++ sql statements.

    "Having" is supported by the query framework. For example, look at Walkthrough: Creating an AOT Query that has Group By and Having Nodes [AX 2012].

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans