怎么查询多列值的出现频率

如何查询多列值的出现频率

比如我有一张学生成绩表,行是学生名称,列是科目

如:

   

  语文 数学 英语

  张A 100 99 98

  王C 99 99 98

  李Z 89 87 100

如何才能查询出 这张表一百分出现的次数 99分出现的次数 等等

希望大家帮帮忙



select s,count(*) from (

select 语文 as s from 学生成绩表

union all

select 数学 from 学生成绩表

union all

select 英语 from 学生成绩表

) t

group by s




select count(*)

from (

select 语文 as score from 学生成绩表

union all

select 数学 as score from 学生成绩表

union all

select 英语 score from 学生成绩表

)Tscore 

where score =100


SELECT sum(iif(语文>=100,1,0))+sum(iif(数学>=100,1,0))+sum(iif(英语>=100,1,0)),

sum(iif(语文=99,1,0))+sum(iif(数学=99,1,0))+sum(iif(英语=99,1,0))

 from tty 

or

select count(*)

from (

select 语文 as score from 学生成绩表

union all

select 数学 as score from 学生成绩表

union all

select 英语 score from 学生成绩表

)Tt

group by score

怎么查询多列值的出现频率

相关文章:

你感兴趣的文章:

标签云: