题解 | #返回每个订单号各有多少行数#
返回每个订单号各有多少行数
https://www.nowcoder.com/practice/cf1f8d4a514d455aa0468718fb411f41
题意分析:
每个订单号(order_num)各有多少行数(order_lines),并按 order_lines对结果进行升序排序
- 每个订单号:使用
group by
分组 - 各有多少行数:
count()
函数进行统计
select order_num, count(order_num) as order_lines from OrderItems group by order_num order by order_lines#MySQL#