最常见的一种
select count(*) from goods group by goods_id;
商品数量少的话可以用下面两种写法
select sum(IF(goods_id=1,1,0)) as a,sum(goods_id=2,1,0) as b from goods;
select count(IF(goods_id=1 or null)) as a,count(goods_id=2 or null) as b from goods;