34,593
社区成员
发帖
与我相关
我的任务
分享
select 字段1,
sum(case when 状态='OK' then 1 else 0 end),
sum(case when 状态='NOthen 1 else 0 end),
count(*)
from student
group by 字段1
select 字段1,
sum(case when 状态='OK' then 1 else 0 end) as '状态为OK条数',
sum(case when 状态='No' then 1 else 0 end) as '状态为No条数',
count(*) as '总条数'
from table_name
group by 字段1