微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有学生科目成绩表这三张表要求查处各个科目的前三名成绩

create table student( sid int identity(1,1) primary key, sname varchar(20) not null)create table coures(  cid int identity(1,  cname varchar(20))create table score(   scid int identity(1,   sid int not null,   cid int not null,   result float)insert into student values('张学友')insert into student values('吴孟达')insert into student values('张柏芝')insert into student values('曹阿瞒')insert into student values('张牛俊')insert into coures values('计算机科学与应用')insert into coures values('高等数学')insert into coures values('线性代数')insert into score values(1,1,80)insert into score values(1,2,78)insert into score values(1,3,59)insert into score values(2,84)insert into score values(2,90)insert into score values(2,45)insert into score values(3,23)insert into score values(3,87)insert into score values(4,100)select * from student select * from couresselect * from score--查询出 各个科目的前三名(圆满解决)select cid,result from score s group by cid,result  having resultin(   select top 3 result  from score where cid = s.cid order by result desc)order by cid,result desc

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐