GATE 2015 CS (CS1) – Question 61
Consider the following relations:
Student
| Roll_No | Student_Name |
|---|---|
| 1 | Raj |
| 2 | Rohit |
| 3 | Raj |
Performance
| 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_NameThe number of rows that will be returned by the SQL query is ________.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 2
Explanation
The query groups the joined rows by student name, not by roll number. The names are Raj, for roll numbers 1 and 3, and Rohit, for roll number 2. That gives two groups, so the query returns 2 rows.
More Relational Model: Relational Algebra, Tuple Calculus, SQL questions
- GATE 2017 CS (CS1) Q33
- GATE 2017 CS (CS1) Q51
- GATE 2017 CS (CS1) Q56
- GATE 2014 CS (CS1) Q64
- GATE 2014 CS (CS2) Q64
- GATE 2014 CS (CS3) Q31
All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →