本文介绍了要选择一个非聚合函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4张桌子:

学生:

student_id(PK)
student_name
section_ID

部分:

section_ID(PK)
section

班级:

class_ID(PK)
class
section_ID

标记:

student_id(CK)
subject_id(CK)
marks

使用以下代码

SELECT Class.Class, MAX(Marks.Marks) AS Total_Marks
FROM Marks, Class, Student, Section
WHERE Marks.Student_ID = Student.Student_ID
AND Student.Section_ID = Section.Section_ID
AND Section.Section_ID = Class.Section_ID
GROUP BY Class.Class

我能够在每个班级中找到最高分,但我也想显示学生的姓名或学生ID

I'm able to find the highest marks from every class but I want to display the name of the student too OR studentID

请帮帮我我正在使用MS ACCESS

Help me out pleaseI'm using MS ACCESS

推荐答案

select st.student_name, max(marks)
    from student st, student_id s, section s
    where marks= (select max(marks)
    from student_id) and s.student_id = st.student_id
and st.section_id = s.section_id
group by st.student_name

这篇关于要选择一个非聚合函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 06:52