select a.type,
sum(case when a.status='审核成功数' then 1 else 0 end) as 审核成功数,
sum(case when a.status='失败数' then 1 else 0 end) as 失败数,
sum(case when a.status='等待审核数' then 1 else 0 end) as 等待审核数
from tablename as a group by a.type
select t.type,
sum(decode(t.status, '审核成功', 1, 0)) as '审核成功数',
sum(decode(t.status, '审核失败', 1, 0)) as '审核失败数',
sum(decode(t.status, '等待审核', 1, 0)) as '等待审核数'
from table_name t
group by t.type
提示一下:首先你这个要分类,先使用case type when…then…语句,求和使用Sum()方法,统计数量使用Count()方法,最后按照你的查询分组字段type分组即可……
select [type],
SUM(case when status='审核成功' then 1 else 0 end) as 审核成功数,
SUM(case when status='审核失败' then 1 else 0 end) as 审核失败数,
SUM(case when status='等待审核' then 1 else 0 end) as 等待审核数
from [Check] group by [type]