我有一个销售 ID 列表,后跟他们的总销售额和购买量。我现在想总结总销售额和购买量。我试图插入 sum totalbuy 和 totalsell 作为总数。但这并没有奏效。
select sales_id,
SUM(CASE WHEN side= 'buy' THEN 1 ELSE 0 END) AS totalbuy,
SUM(CASE WHEN side= 'sell' THEN 1 ELSE 0 END) AS totalsell
from car_orders
where sales_id like '%%'
GROUP BY sales_id