0

当我在我的选择语句上使用汇总时,如果返回查询中最后一条记录的值。

SELECT product_name, (item_price-discount_amount)*quantity AS "total_amount" 
FROM products JOIN  order_items  ON products.product_id=order_items.product_id 
GROUP BY products.product_name WITH ROLLUP;

查询返回 product_name 和 total_amount。汇总的 product_name 为空,但 total_amount 与最后一条记录相同。如何获得需要与汇总一起使用的 total_amount 的总和,但我似乎无法修复它

4

0 回答 0