Write a query to find the name of the student(s) who has scored maximum mark in Software Engineering. Sort the result based on name

前端 未结 4 1261
生来不讨喜
生来不讨喜 2020-12-22 05:24

Write a query to find the name of the student(s) who has scored maximum mark in Software Engineering. Sort the result based on name.

This is what I tried.

         


        
4条回答
  •  渐次进展
    2020-12-22 06:00

    You can try this code. It must work perfectly :

     select s.student_name
        from student s
        join mark m
        on s.student_id=m.student_id
        join subject s1
        on s1.subject_id=m.subject_id
        where m.value=(select max(m1.value) from mark m1 
                         join subject s2
                         on s2.subject_id=m1.subject_id
                         where lower(s2.subject_name)='software engineering'
        group by s2.subject_id)
        group by s.student_name
        order by s.student_name;
    

提交回复
热议问题