2021-04-22
阅读量:
859
SQL求每个客户下单最多的分类,以及在该分类上的总消费金额该怎么写?
问:这里求每个客户下单最多的分类,以及在该分类上的总消费金额该怎么写?
答:select customer_id,order_category,t.order_amt
from (select customer_id,order_category,sum(order_amt) as order_amt,
ROW_NUMBER() over (PARTITION By customer_id order by order_amt desc) as 排名
from kehu
group by customer_id,order_category) t
where 排名=1;






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论