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)
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

    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

    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
    237,978 Most Valuable Professional on at

    "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…

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