首页 > 代码库 > count统计与分组

count统计与分组

1、SELECT cate_name as cateName,count(cate_name) as count FROM `intl_order_goods` where order_id = 1 group by cate_name

执行结果:

技术分享

2、SELECT cate_name as cateName,count(cate_name) as count FROM `intl_order_goods` where order_id = 1

技术分享

这个结果不正确,没有意义。

3、总结:

只要有count(xxx),就会统计,显示结果为一条。这里配合分组使得结果有了意义。

count统计与分组