Skip to content

ISRO Scientist/Engineer CSE 2018Databases › SQL

ISRO Scientist/Engineer CSE 2018 PYQ: Consider the set of relations given below and the SQL query that follows: Students: (Roll_number, Name,…

Consider the set of relations given below and the SQL query that follows:

Students: (Roll_number, Name, Date_of_birth)
Coursed: (Course_number, Course_name, Instructor)
Grades: (Roll_number, Course_number, Grade)
SELECT DISTINCT Name
FROM Students, Courses, Grades
WHERE Students.Roll_number = Grades.Roll_number
                            AND   Courses.Intructor =Sriram
                            AND   Courses.Course_number = Grades.Course_number
                            AND   Grades.Grade = A

Which of the following sets is computed by the above query?

  1. A
    Names of Students who have got an $\textsf{A}$ grade in all courses taught by Sriram
  2. B
    Names of Students who have got an $\textsf{A}$ grade in all courses
  3. C
    Names of Students who have got an $\textsf{A}$ grade in at least one of the courses taught by Sriram
    Correct answer
  4. D
    None of the above

Answer

(C) Names of Students who have got an $\textsf{A}$ grade in at least one of the courses taught by Sriram

Approach

The query joins Students, Courses, and Grades on matching roll numbers and course numbers, filters courses taught by Sriram and grades equal to 'A', then projects distinct student names. This is a conjunctive (AND) selection, so it returns students who have an 'A' in at least one course taught by Sriram, not necessarily all such courses.

Reviewed by ISRO IQ Editorial Team.