Consider the following tables (relations): Primary keys in the tables are…

2018

Consider the following tables (relations):

Primary keys in the tables are shown using underline. Now, consider the following query:

SELECT S.Name, Sum (P.Marks) FROM Students S , Performance P WHERE S.Roll-No=P.Roll-No

GROUP BY S.Name

The number of rows returned by the above query is

  1. A.

    0

  2. B.

    1

  3. C.

    2

  4. D.

    3

Attempted by 357 students.

Show answer & explanation

Correct answer: C

Key idea: join Students with Performance on Roll-No, then group the results by student name. Students who share the same name are combined into a single group.

Step-by-step calculation:

  • For roll number 18CS101 (Name: Ramesh): Marks = 60 + 65 = 125

  • For roll number 18CS102 (Name: Mukesh): Marks = 80 + 75 = 155

  • For roll number 18CS103 (Name: Ramesh): Marks = 85 + 70 = 155

Now group these results by student name:

  • Ramesh: 125 (from 18CS101) + 155 (from 18CS103) = 280

  • Mukesh: 155 (from 18CS102)

Final answer: The query returns 2 rows (one for Ramesh and one for Mukesh).

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

Explore the full course: Mppsc Assistant Professor