SELECT order_num, COUNT(order_num) AS items FROM OrderItems GROUP BY order_num HAVING items >= 3 ORDER BY items
这道题需要获取到order_num(订单号)的次数,找到次数大于3的,需要对order_num进行计数,然后对订单号进行分组,然后获取到次数大于3的订单数,再对次数进行排序
SELECT order_num, COUNT(order_num) AS items FROM OrderItems GROUP BY order_num HAVING items >= 3 ORDER BY items
这道题需要获取到order_num(订单号)的次数,找到次数大于3的,需要对order_num进行计数,然后对订单号进行分组,然后获取到次数大于3的订单数,再对次数进行排序