
今天就做一个题!
记录日常SQL练习题,默认使用oracle
code_new_life
这个作者很懒,什么都没留下…
展开
-
2020.4.12练习
题目参考 [https://www.jianshu.com/p/476b52ee4f1b] 参考数据: -- 学生表 Student create table Student(SId varchar(10),Sname varchar(10),Sage datetime,Ssex varchar(10)); insert into Student values('01' , '赵雷' , '199...原创 2020-04-12 23:34:23 · 238 阅读 · 0 评论 -
20200419练习
查询各科成绩前三名的记录 但凡遇到排名类问题,一个基本思路是直接自联结,然后根据要求,在where中添加条件即可;本题要求科目前三,则筛选同科目比自己大成绩数小于3即可 select s.cid,s.sid,s.score from sc s where (select count(*) from sc a where s.cid = a.cid ...原创 2020-04-19 22:23:43 · 265 阅读 · 0 评论 -
2020.4.15练习
按各科成绩进行排序,并显示排名, Score 重复时合并名次 select a.cid, a.sid, a.score, count(distinct b.score)+1 as rank from sc a left join sc b on a.score<b.score and a.cid = b.cid group by a.cid, a.sid,a.score order...原创 2020-04-15 22:16:44 · 264 阅读 · 0 评论