Consider the following relations: Student Table Roll_No Student_Name 1 Raj 2…
2015
Consider the following relations:
Student Table
Roll_No | Student_Name |
1 | Raj |
2 | Rohit |
3 | Raj |
Performance Table
Roll_No | Course | Marks |
1 | Math | 80 |
1 | English | 70 |
2 | Math | 75 |
3 | English | 80 |
2 | Physics | 65 |
3 | Math | 80 |
Consider the following SQL query.
SELECT S.Student_Name, Sum(P. Marks) FROM Student S, Performance P WHERE S.Roll_No= P.Roll_No GROUP BY S.STUDENT_Name
The numbers of rows that will be returned by the SQL query is_________________.
Attempted by 164 students.
Show answer & explanation
Correct answer: 2
Answer: 2 rows
Explanation:
Join matches each Performance row to the corresponding student by Roll_No.
Sum the marks per student record: Roll_No 1 (Raj) has 80 + 70 = 150; Roll_No 3 (Raj) has 80; Roll_No 2 (Rohit) has 75 + 65 = 140.
Grouping by Student_Name combines the two Raj rows (from Roll_No 1 and 3) into one group. The distinct names after grouping are Raj and Rohit, so the query returns 2 rows.
A video solution is available for this question — log in and enroll to watch it.