Hi @EM ,
Welcome to Microsoft Q&A!
We recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data and the expected result of the sample after updating.
Please have a try with below update statement and check whether it is helpful.
update a
set a.[CabinetCount]=b.cabCount
from @SubmittedOrders a
inner join
(SELECT d.OrderID ,COUNT(*) AS cabCount
FROM tableDDDD d
INNER JOIN tableOO o ON o.OrderID = d.OrderID
WHERE (d.LineType = 'LC') AND (o.A = 'SUBMITTED')
group by d.OrderID) b
on a.OrderID=b.OrderID
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.