Хотите выбрать не агрегатную функцию - PullRequest
0 голосов
/ 02 июля 2019

У меня есть 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

Я могу найти самые высокие оценки в каждом классе, но я также хочу вывести имя ученика ИЛИ studentID

Помоги мне, пожалуйста Я использую MS ACCESS

1 Ответ

0 голосов
/ 02 июля 2019
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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...