题解 | #返回每个订单号各有多少行数#
返回每个订单号各有多少行数
https://www.nowcoder.com/practice/cf1f8d4a514d455aa0468718fb411f41
select order_num,count(order_num) as order_lines from OrderItems group by order_num order by order_lines
知识点:
1、count(*),count(列名)都可以,区别在于,count(列名)是统计非NULL的行数
2、order by最后执行,所以可以使用列别名
3、分组聚合一定不要忘记加上 group by ,不然只会有一行结果