不知为啥,当我得查询中出现distinct时,order by 中必须包含要查询的列,否则报错. SELECT DISTINCT a.DetailId, a.OrderId, a.ProductId, pi2.BarCode, pi1.ProductName, pi1.productCode, pi1.spec, a.UnitId, ui.UnitName, SNUM(a.DetailId) as Quantity, a.Discount, a.UnitPrice, a.TaxRate, a.P…