复杂分组查询 查询订单数量和订单总金额 根据国家分组

业务:查询订单数量和订单总金额 根据国家分组

当然还有别的条件,这里不全写了
select count(DISTINCT t.customer_id) as customerNum, 去重统计一个国家的下单客户数
sum(t.total_amount) as saleAmount, 统计一个国家的销售金额
count(t.id) as orderNum, 统计一个国家的订单数量
t.industry, 行业 这里行业暂时都是一样的,因为where里有别的条件
tci.country 国家
from trade_order t left join trade_customer_info tci on t.customer_id = tci.id
where t.is_delete = 0
GROUP BY tci.country


posted @ 2022-01-19 15:35  了悟  阅读(154)  评论(0编辑  收藏  举报