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;
}
}

  • ShaishavM Profile Picture
    215 on at
    RE: SqlJoinType

    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.  

  • KevTheDev Profile Picture
    10 on at
    RE: SqlJoinType

    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?

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans