时间:2021-07-01 10:21:17 帮助过:2人阅读
2.测试数据
select * from student ; insert into student(name,subject,score) values(‘张‘,‘语文‘,96) ; insert into student(name,subject,score) values(‘张‘,‘数学‘,62) ; insert into student(name,subject,score) values(‘张‘,‘英语‘,85) ; insert into student(name,subject,score) values(‘王‘,‘语文‘,12) ; insert into student(name,subject,score) values(‘王‘,‘英语‘,100) ; insert into student(name,subject,score) values(‘李‘,‘数学‘,10) ; insert into student(name,subject,score) values(‘赵‘,‘英语‘,88) ;
student表 ,一共三个字段 name ,subject ,score (数据类型分别为 varchar(50),varchar(50),int),测试表,比较简单。
3.我写的sql
select m.name from ( select s.name ,s.score ,DENSE_RANK() over(PARTITION by s.name order by s.score asc) as score_rank from student s ) m where m.score_rank = 1 and m.score >=60 ;
如有异议,欢迎指正。
面试题:sql数据查询
标签: