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 :
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
    215 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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,098

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,556 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,108 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans