测试工程师笔试题整理01( 二 )


1、有下表:(10)
table(
(50)null,(学号)
kc (50)null,
(课程)score (18,1)null(成绩)
用一条语句取出每课成绩前两名的学生信息并按课程号和成绩排序
方法一:(表自连接)
* froma where ( count(*) fromb where a.kc = b.kc and a.score< b.score)
order by kc,score desc
分析:
mysql中查询每门课程成绩最好的前两名_绝 情 谷 主的博客-CSDN博客_查询每门功成绩最好的前两名
方法二:
a.* fromas a where a. in (top 2fromwhere kc=a.kc order by score dese)
方法三:
,kc, max(score) as score fromgroup by kc union
,kc,max(score) fromas a where score not in( max(score)fromb where a.kc = b.kc group by kc) group by kc order by kc,score desc
2、有下表
aa
80
bb
90
cc
95
dd
70
ee
60
用一条语句输出,成绩在90分以上的评为:“”,80-90分的评为"GOOD",其他评为”SOSO”
id,name,score
case when score>90 then’’
when score>80 and score