这就是我得到的这个 SQL 代码的错误。我不知道修复它的最佳方法。
SELECT
muo.VehicleReferenceCode as REF#,
CONVERT(CHAR(10), muo.ActualDeliveryDate, 101) as 'Date In',
vd.Model as Model,
muo.DealerCategoryCode as 'Cat.',
v.PurchaseSourceVendorCode as Vendor,
muo.VendorCost + muo.FactoryOptionsCost as 'VEH Cost',
muo.FreightCostAmt as Freight,
muo.TransferredPDIPartsCost + muo.TransferredPDILaborCost as 'Trans Cost',
SUM(woeid.h_ListPrice) - SUM(woeid.DiscountAmt) as 'Int P&A Charge',
SUM(woeld.RegularLaborAmt) - SUM(woeld.DiscountAmt) as 'Int Labor Charge',
muo.VendorCost
+ muo.FactoryOptionsCost
+ muo.FreightCostAmt
+ muo.TransferredPDIPartsCost
+ muo.TransferredPDILaborCost
+ SUM(woeid.h_ListPrice)
- SUM(woeid.DiscountAmt)
+ SUM(woeld.RegularLaborAmt)
- SUM(woeld.DiscountAmt) as 'VEH Total'
FROM MajorUnitOrder muo
INNER JOIN Vehicle v
ON muo.VehicleIdentificationNum = v.VehicleIdentificationNum
JOIN VehicleDesignator vd
ON v.VehicleDesignatorCode = vd.VehicleDesignatorCode
JOIN WorkOrder wo
ON v.VehicleIdentificationNum = wo.VehicleIdentificationNum
JOIN WorkOrderEventItemDetail woeid
ON wo.WorkOrderCode = woeid.WorkOrderCode
JOIN WorkOrderEventLaborDetail woeld
ON woeid.WorkOrderCode = woeld.WorkOrderCode