select 学号,姓名,count(*) as 卫生 from Agroup by 学号,姓名
select 学号,姓名,count(*) as 学习 from Agroup by 学号,姓名
select 学号,姓名,count(*) as 劳动 from Agroup by 学号,姓名
select 学号,姓名,count(*) as 才艺 from Agroup by 学号,姓名
select stu_id as 学号,stu_name as 姓名, count(case stu_prize when '卫生' then '卫生' end) '卫生', count(case stu_prize when '学习' then '学习' end) '学习', count(case stu_prize when '劳动' then '劳动' end) '劳动', count(case stu_prize when '才艺' then '才艺' end) '才艺'
from t_stu
group by stu_id,stu_name
order by stu_id
go