Mysql统计查询订单笔数超过15笔的上海客户的订单情况,输出客户名称,订单次数,订单总额(订单金额之和),结果按客户名升序排列。
时间: 2023-05-20 21:01:21 浏览: 234
以下是 SQL 查询语句:
SELECT
customer_name,
COUNT(order_id) AS order_count,
SUM(order_amount) AS total_amount
FROM
orders
WHERE
customer_city = '上海'
GROUP BY
customer_name
HAVING
COUNT(order_id) > 15
ORDER BY
customer_name ASC;
这个查询语句会统计上海客户的订单情况,输出客户名称、订单次数和订单总额,结果按客户名升序排列。
阅读全文