mysql查找订单总金额少于2000的客户
您可以使用以下SQL查询语句来查找订单总金额少于2000的客户:
SELECT customer_id, SUM(total_amount) AS total_amount
FROM orders
GROUP BY customer_id
HAVING total_amount < 2000;
这个查询语句首先对订单表进行分组,然后计算每个客户的订单总金额,最后筛选出订单总金额小于2000的客户。请确保将orders替换为您实际的订单表名称。
原文地址: https://www.cveoy.top/t/topic/iSTC 著作权归作者所有。请勿转载和采集!