I have a sql query with that adds numerical values from different table to find total for a shipment.
When I execute this query, it works fine for the first record but rest of the records show null value when I know there are records present.
SQL pros please take a look and let me know if there is a problem with my syntax.
SELECT InID, InDate, OrderID,
(SELECT CompanyName
FROM tblCompany
WHERE (CompanyID = tblIn.ShipperID)) AS SHIPPER,
(SELECT CompanyName
FROM tblCompany AS tblCompany_1
WHERE (CompanyID = tblIn.CarrierID)) AS CARRIER, Tracking, BolQty,
(SELECT COUNT(ControlID) AS Expr1
FROM tblInventoryDetail
WHERE (InID = tblIn.InID)) +
(SELECT COUNT(*) AS expr1
FROM tblWrongRA
WHERE (InID = tblIn.InID)) +
(SELECT SUM(Qty) AS Expr1
FROM tblInBulk
WHERE (InID = tblIn.InID)) AS QTY,
(SELECT Fname + ' ' + Lname AS Expr1
FROM tblUser
WHERE (EmpID = tblIn.EmpID)) AS 'USER', TimeRecord
FROM tblIn