一个人的婚纱写真:一个简单的SQL编程问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 04:11:18
查询score 表中的最高分的学生学号和课程号

我的书上是这么写的

select sno as '学号',cno as '课程号',max(score)as '最高分'
from score

但是我在查询管理器里面却调试不出来
告诉我书上哪里错了?这个查询语句应该怎么写呢?
正确的结果应该是这样的

学号 课程号 最高分
108 6-166 92

不明白书中的意思
select sno as '学号',cno as '课程号',max(score)as '最高分'
from score group by sno,cno
这样就可以运行了,不过得不到你想要的东西
应该改成
select sno as '学号',cno as '课程号',score as '最高分'
from score where score in (select max(score) from score)

select sno as '学号',cno as '课程号',score as '最高分'
from score where score in (select max(score) from score)

select sno as 学号,cno as 课程号,score as 最高分
from score where score = (select max(score) from score)

select sno as '学号',cno as '课程号',max(score)as '最高分' from score group sno
如果还不行。

你看一下是不是别的原因。比如说数据库里的字段名都是不是sno,cno,score 还有表的名字是不是score

select sno as '学号',cno as '课程号',score as '最高分'
from score where score in (select max(score) from score)

select sno cno from *** as max( sno cno)