Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Select and group by subStr()

(0) ShareShare
ReportReport
Posted on by 495

4760.query.png

why error??

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    RE: error query in code x++ class

    Because such syntax isn't valid. You can't ask SQL Server to execute X++ methods, and AX doesn't have any feature to directly  translate X++ method calls to SQL functions. Get used to consulting Select statement syntax.

    Regarding the field selection, you could fetch the whole LedgerAccount from database and than extract the substring in X++. Unfortunately you can't group by the function in any way in pure X++, but the solution would be a view with a computed column. You should be able to group by that.

    Nevertheless note that it's a suspicious activity - it seems to suggest that you have multiple pieces of data in a single attribute, which is a violation of normal forms. The query would be much easier and much more efficient if you've designed the schema (or the way how you use the standard schema) correctly.

  • Suggested answer
    Iulian Cordobin Profile Picture
    Iulian Cordobin 8,201 on at
    RE: error query in code x++ class

    Because AX doesn't know how to call that function in a select statement.

    You can however perform the select on the field (remove the subStr from the while select), and then in the while's block get the substring you need in the = line you perform.

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans