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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Subquery for Business Central AL?

(0) ShareShare
ReportReport
Posted on by

A client that just migrated to Business Central from Nav 5.0 has a complex query from SQL that involved subqueries. Does AL support this, and anyone have an example? As an example of the SQL query, one piece of it is below:

SELECT LastOpTable.[Prod_ Order No_], LastOpTable.LastOp, [COMPANY Live DB$Prod_ Order Routing Line_4].Description AS LastProdRoutingDescription,
[COMPANY Live DB$Prod_ Order Routing Line_4].[Ending Date] AS LastProdRoutingEndDate
FROM dbo.[COMPANY Live DB$Prod_ Order Routing Line] AS [COMPANY Live DB$Prod_ Order Routing Line_4] RIGHT OUTER JOIN
(SELECT [Prod_ Order No_], MAX([Operation No_]) AS LastOp
FROM dbo.[COMPANY Live DB$Prod_ Order Routing Line] AS [COMPANY Live DB$Prod_ Order Routing Line_3]
WHERE (Status = '3')
GROUP BY [Prod_ Order No_]) AS LastOpTable ON [COMPANY Live DB$Prod_ Order Routing Line_4].[Prod_ Order No_] = LastOpTable.[Prod_ Order No_] AND
[COMPANY Live DB$Prod_ Order Routing Line_4].[Operation No_] = LastOpTable.LastOp

Any guidance or ideas would be greatly appreciated.

Thanks

  • Samantha73 Profile Picture
    3,420 on at

    My view is AL query object is limited in what it can do and I'd use functions to get advanced calculations within the dataset for RDLC or if its a list page

  • Suggested answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    Are you planning to use AL or Query object, you can definitely code all your queries in AL, for complex you might have to use some temp tables to store and query.

  • kjjson Profile Picture
    on at

    What would you recommend? I am new to this (long time Dynamics GP/SQL user, but AL and Business Central is a whole new world, and the examples I find are pretty basic.

    Thanks,

    Kevin

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 677 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 430 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 280 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans