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...
Unanswered

SqlJoinType

(0) ShareShare
ReportReport
Posted on by 10

I am trying to sum the costs of certain items in the Prod Order Component table using a DataItemTableFilter and then do a left join to the Prod. Order Line table so I still get all records even when the filter parts are not found, should just return a null in the CostAmount column.

However, the LeftOuterJoin does not seem to work as I am not getting any records from the Prod. Order Line table when there is not match found in the filtered Component table.

Any idea what I am doing wrong or should I be doing this differently.

dataitem(ProdOrderComponent; "Prod. Order Component")
{
DataItemLink = "Prod. Order No." = ProductionLine."Prod. Order No.", "Prod. Order Line No." = ProductionLine."Line No.";
SqlJoinType = LeftOuterJoin;
DataItemTableFilter = "Item No." = filter('PT001821' | 'PT001894' | 'PT001934');

column(CostAmount; "Cost Amount")
{
Method = Sum;
}
}

I have the same question (0)
  • KevTheDev Profile Picture
    10 on at

    In SQL it would be something like...

    From [Productione Line] P
    Left Outer Join (
        Select [Prod. Order No.], [Prod. Order Line No.], Sum([Cost Amout]) As CostAmount 
        From [Prod. Order Component] 
        Where [Item No.] In ('PT001821','PT001894','PT001934') 
        Group By [Prod. Order No.], [Prod. Order Line No.]
        ) C
    On P.[Prod. Order No.] = C.[Prod. Order No.] And P.[Line No.] = C.[Prod. Order Line No.]


    but not sure how this is done in AL?

  • ShaishavM Profile Picture
    225 on at

    Hi KevTheDev, I am sure you checked filtered data (Item No) exists on both tables.

    I noticed that even though record exists in parent table (Item no), if the linked table doesn't have the matching records, query returns null.  

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,003 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,225 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,192

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans