Consider the table Student(stuid, name, course, marks). Which one of the…

2013

Consider the table Student(stuid, name, course, marks).
Which one of the following two queries is correct to find the highest marks student in course 5? (NET-DEC-2013)
Select S.stuid
From student S
Where not exists (select *
  from student e
  where e.course = ‘5’ and e.marks ≥ s.marks)

Select s.stu.id
From student S
Where s.marks > any (select distinct marks
  from student S
  where s.course = 5)

  1. A.

    Q.1

  2. B.

    Q.2

  3. C.

    Both Q.1 and Q.2

  4. D.

    Neither Q.1 nor Q.2

Attempted by 83 students.

Show answer & explanation

Correct answer: D

Query 1 is correct. It uses the NOT EXISTS pattern to identify students in course 5 who have no other student with higher or equal marks, effectively finding the maximum. Query 2 contains a syntax error (stu.id vs stuid) and incorrect logic for this purpose.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor