姓名 语文 数学 物理 化学 政治 英语
小王 89 61 45 66 78 61
小红 87 67 56 96 88 67
小妹 67 78 68 43 87 86
小美 89 65 56 67 65 73
小梅 56 56 59 65 70 78
小李 90 59 76 45 90 54
小张 63 57 76 55 76 56
小章 59 55 56 56 78 89
小虎 58 45 56 67 77 90
小胡 76 60 67 78 67 66
小王 89 61 45 66 78 61
小红 87 67 56 96 88 67
小妹 67 78 68 43 87 86
小美 89 65 56 67 65 73
小梅 56 56 59 65 70 78
小李 90 59 76 45 90 54
小张 63 57 76 55 76 56
小章 59 55 56 56 78 89
小虎 58 45 56 67 77 90
小胡 76 60 67 78 67 66
create table test (姓名 varchar(10),语文 int,数学 int,物理 int,化学 int,政治 int,英语 int)
insert test
select '小王',89,61,45,66,78,61union all
select '小红',87,67,56,96,88,67union all
select '小妹',67,78,68,43,87,86union all
select '小美',89,65,56,67,65,73union all
select '小梅',56,56,59,65,70,78union all
select '小李',90,59,76,45,90,54union all
select '小张',63,57,76,55,76,56union all
select '小章',59,55,56,56,78,89union all
select '小虎',58,45,56,67,77,90union all
select '小胡',76,60,67,78,67,66
select 语文=convert(varchar,SUM(case when 语文>=60 then 1 else 0 end)*100/COUNT(语文))+'%',
数学=convert(varchar,SUM(case when 数学>=60 then 1 else 0 end)*100/COUNT(数学))+'%',
物理=convert(varchar,SUM(case when 物理>=60 then 1 else 0 end)*100/COUNT(物理))+'%',
化学=convert(varchar,SUM(case when 化学>=60 then 1 else 0 end)*100/COUNT(化学))+'%',
政治=convert(varchar,SUM(case when 政治>=60 then 1 else 0 end)*100/COUNT(政治))+'%',
英语=convert(varchar,SUM(case when 英语>=60 then 1 else 0 end)*100/COUNT(英语))+'%'
from test
/*
70% 50% 40% 60% 100% 80%
*/