SQL GROUP BY分组后分别计算组内不同值的数量

SQL GROUP BY分组后分别计算组内不同值的数量

select name as 姓名,
sum( case when cargo='笔' then 1 else 0 end ) as 笔,
sum( case when cargo='橡皮' then 1 else 0 end ) as 橡皮
from shopping group by name;
posted @ 2022-03-10 09:27  爱我的幸运  阅读(299)  评论(0)    收藏  举报