首页 > 试题广场 >

一个学生表,一个课程成绩表,怎么找出学生课程的最高分数

[问答题]
现在有一个学生表,一个课程成绩表,请问,怎么找出学生课程的最高分数,谈一谈思路
学生表(child):id ,student(姓名)
成绩表(grade):id,grade,childid;
语句:select c.student,MAX(g.grade) from grade g,child c where c.id=g.childid group by c.id;
返回每个学生的最高成绩
发表于 2019-03-14 16:02:38 回复(2)
两个表根据学生id进行连接,然后对学生进行分组,找出每一组成绩最高的学生信息
发表于 2019-08-03 17:39:23 回复(0)
两个表唯一的关联就是学生的id了,可以用内连接查询,以id相等为条件,成绩表中用max()取该id的最高成绩
发表于 2019-02-15 19:56:54 回复(0)
group by 學生ID,然后max(成绩)
发表于 2020-11-29 18:25:14 回复(0)
select * from score where stu_id=? and score.score exists ( select max(score) form score where stu_id=?) 
发表于 2020-10-28 16:52:43 回复(0)
发出连接释放请求
发表于 2020-04-29 12:06:57 回复(0)
select * from score where stu_id=? and score.score exists ( select max(score) form score where stu_id=?) 不知对否,望各位指正
发表于 2019-06-27 23:40:32 回复(0)
两个表进行连接,对学生进行分组,找出每一组成绩最高的学生信息
发表于 2019-04-24 10:56:58 回复(0)
通过学生ID内联学生表和课程成绩表,然后拿成绩字段做降序排列直接取出第一条即可
发表于 2019-03-13 09:29:51 回复(0)

Select stu_id,stu_grade

From student join grade

On stu_id where stu_grade=max(stu_grade)

发表于 2019-02-24 22:55:11 回复(0)