I would like to roll up the qty in my Details table and / that by a number by another number stored in another table. the statement checks out when i parse it. but when i run it. i get the error Invalid column name UnitLoads. any suggestions on how to roll up a qty and / it by another value? and a side question is there a better way to write this statement?
Cheers.
Cheers.
Code:
select '708971' + B.ItemNumber as UPC, B.ItemNumber, D.ItemDescription, sum(cast(B.Quantity as int)) as Qty, B.OrderNumber, D.Weight,
cast((cast(B.Quantity as int) / E.PercentUnitLoadMult) as float) as UnitLoads,
A.ShippedDate, A.ShipTo_Name, A.ShipTo_Address, A.ShipTo_Address2, A.ShipTo_City, A.ShipTo_State, A.ShipTo_Zip,
A.OrderNumber, A.CarrierName, C.LoadNumber, C.StopNumber
from Confirmationheader A INNER JOIN
ConfirmationDetail B
ON A.OrderNumber = B.OrderNumber
INNER JOIN
TranWorking..tblOrderMasterfile C
ON C.OrderNumber = B.OrderNumber
INNER JOIN
QueryMaster..IM1_InventoryMasterfile D
ON D.ItemNumber = B.ItemNumber
INNER JOIN
TranMaster..tblInventoryMasterfile E
ON
E.ItemNumber = B.ItemNumber
group by B.OrderNumber, B.ItemNumber, A.ShippedDate, A.ShipTo_Name, A.ShipTo_Address, A.ShipTo_Address2, A.ShipTo_City, A.ShipTo_State, A.ShipTo_Zip,
A.OrderNumber, A.CarrierName, C.LoadNumber, C.StopNumber, D.ItemDescription, D.Weight, UnitLoads