Hi Folks
I'm trying to collect data from two tables where I would ordinarily use a left join on the columns that relate the tables. But I'm trying to bring back a count of items from the second table where on the column being used where the table repation would take place. Something like this:
I'm trying to collect data from two tables where I would ordinarily use a left join on the columns that relate the tables. But I'm trying to bring back a count of items from the second table where on the column being used where the table repation would take place. Something like this:
Code:
SELECT COUNT(wb.WaybillID),
Tr.TrID,
Tr.TrName,
CAST(Tr.trMaxCars * (Tr.TrPctThru * 0.01) AS integer) as TrCarLimit,
Tr.TrFromStagingArea
FROM Train Tr LEFT JOIN Waybill wb ON tr.TrID = wb.TrainAssignment WHERE Tr.TrOriginateOL = 'Y' GROUP BY Tr.TrID