group by 后怎么知道每组的个数

group by 后怎么知道每组的个数

group by 后如何知道每组的个数。

假如统计订单表中各个商品总购买量像这样。

select   sum(quantity)   from   order   group   by   product_id

但我又想知道每个group组中商品有几条记录怎么办,可以通过这个语句或是可以通过一个语句来实现吗?



加上count(*)

select sum(quantity),count(*) from order group by product_id

group by 后怎么知道每组的个数

相关文章:

你感兴趣的文章:

标签云: