关系数据库(如MySQL),已知表t_order为订单表,有字段prod_id(产品种类id),user_id(购买用户id),order_time(订单时间)等字段。现统计每种产品购买数量最多的前10个用户找出来,如下哪个语句是正确的?
A. select prod_id, user_id, count(*) as cnt from t_order group by prod_id,user_id having cnt <=10
B. select * from ( select prod_id, user_id, cnt, row_number() over (partition by prod_id order by cnt desc) as rn from (select prod_id, user_id, count(*) as cnt from t_order group by prod_id,user_id) a ) b where rn <=10
C. select * from ( select prod_id, user_id, cnt, row_number() over (partition by user_id order by cnt ) as rn from (select prod_id, user_id, count(*) as cnt from t_order group by prod_id,user_id) a ) b where rn <=10
D. select * from ( select prod_id, user_id, cnt, row_number() over (partition by user_id order by cnt desc) as rn from (select prod_id, user_id, count(*) as cnt from t_order group by prod_id,user_id) a ) b where rn <=10
查看答案
该试题由用户233****10提供
查看答案人数:17578
如遇到问题请
联系客服
正确答案
该试题由用户233****10提供
查看答案人数:17579
如遇到问题请联系客服