GROUP BY 分组问题
SELECT T_Goods_Day_Sale.goods_id, SUM(T_Goods_Day_Sale.qty) AS Expr1, SUM(T_Goods_Day_Sale.ramt) AS Expr2, T_Goods.goods_name,
T_Goods_Day_Sale.ramt - T_Goods.inprc * T_Goods_Day_Sale.qty AS MaoLi,
(T_Goods_Day_Sale.ramt - T_Goods.inprc * T_Goods_Day_Sale.qty)
/ T_Goods_Day_Sale.ramt AS MaoLiLv
FROM T_Goods INNER JOIN
T_Goods_Day_Sale ON T_Goods.Goods_id = T_Goods_Day_Sale.goods_id
WHERE (T_Goods_Day_Sale.sale_date BETWEEN @sale_dateA AND @sale_dateB)
ORDER BY T_Goods_Day_Sale.qty DESC, T_Goods_Day_Sale.ramt DESC, MaoLiLv DESC,
MaoLi DESC
group by good_names
查询的字段都要保留