sql语句:如何查数据库一个表中的一个行的不同项
迪丽瓦拉
2025-03-09 09:35:34
0次
sql语句:如何查数据库一个表中的一个行的不同项
select
max(case t.item1 when 'aa' then count(t.item1) else 0 end) aa,
max(case t.item1 when 'bb' then count(t.item1) else 0 end) bb,
max(case t.item1 when 'cc' then count(t.item1) else 0 end) cc
from 表1 t
group by t.item1
select t.item1, count(*) from 表1 t
group by t.item1
select count(distinct ITEM1) from 表1
就能得出个数啦。
相关内容