各位这个 1 、4.1、6 这三个怎么写啊,有没有会写的,帮我看看吧,这个大数据实在没学过,这个语法不知道啊
##1
select 行政班号,avg(总分) 平均分
from tablename where 专业代码='SC'
group by 行政班号
order by 平均分 desc
limit 1
##4.1
select case when 科目一分数>=20*0.9 then 'A' when 科目一分数>=20*0.8 then 'B' when 科目一分数>=20*0.7 then 'C' when 科目一分数>=20*0.6 then 'D' else 'E' end 等级,count(*) 人数
from tablename
group by case when 科目一分数>=20*0.9 then 'A' when 科目一分数>=20*0.8 then 'B' when 科目一分数>=20*0.7 then 'C' when 科目一分数>=20*0.6 then 'D' else 'E' end
##6
select 行政班号,count(distinct distinct 学号) 人数
from tablename
group by 行政班号
order by 人数 desc
有其他问题可以私聊我,sql我精通
1 select 行政班, avg(总分) from 表 where 专业代码 = 'SC'
group by 行政班
order by avg(总分) desc
limit 1 ;
4.1
首先先把分数跟百分比换算一下 20 满分 18 16 14 12 及格
先求出ABCDE ,然后再根据字段分组求个数
with t1 as (select
case when 科目一 between 18 and 20 then 'A'
when 科目一 < 18 and 科目一 >=16 then 'B'
when 科目一 < 16 and 科目一 >=14 then 'C'
when 科目一 < 14 and 科目一 >=12 then 'D'
when 科目一 < 12 then 'E' end level
from 表)
select level,count(1) from t1 group by level
;
6 select 行政班,count( 学号) from 表
group by 行政班
order by count( 学号) desc ;