我正在尝试编写一个 sql 语句来显示我们所有自己发货的包裹,以便我们可以更新我们的权重。只要我的信息都在一个列中,它就很好用。当我尝试从第二列添加 SKU 时,如果不对 sku 列进行分组,它将无法工作。
--Need to add [Order Details].SKU here while retaining only for orders that match having statement.
SELECT TOP (50) Tracking.OrderNum, Tracking.Pounds, Tracking.Ounces
FROM Tracking INNER JOIN
[Order Details] ON Tracking.OrderNum = [Order Details].OrderNumber AND Tracking.OrderNum = [Order Details].OrderNumber
--Adjustment differentiates items from charges like tax ect.
WHERE ([Order Details].Adjustment = 0)
GROUP BY Tracking.OrderNum, Tracking.Pounds, Tracking.Ounces
HAVING (COUNT([Order Details].OrderNumber) = 1)
ORDER BY CAST(Tracking.OrderNum AS INT) DESC