GATE CSE 2019 Q61: Rows returned by GROUP BY on a cross product without join condition
- Databases
- 2 marks
- NAT
- No negative marking
Syllabus topic: Relational model: relational algebra, tuple calculus and SQL
Question
A relational database contains two tables Student and Performance as shown below:
| Roll_no. | Student_name |
|---|---|
| 1 | Amit |
| 2 | Priya |
| 3 | Vinit |
| 4 | Rohan |
| 5 | Smita |
| Roll_no. | Subject_code | Marks |
|---|---|---|
| 1 | A | 86 |
| 1 | B | 95 |
| 1 | C | 90 |
| 2 | A | 89 |
| 2 | C | 92 |
| 3 | C | 80 |
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;The primary key of the Student table is Roll_no. For the Performance table, the columns Roll_no. and Subject_code together form the primary key. Consider the SQL query given above.
The number of rows returned by the above SQL query is ________.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 5 (official GATE 2019 final answer key)
Concept used: Listing two tables in FROM without a join condition forms their Cartesian product; GROUP BY then returns one row per distinct grouping value that survives the WHERE filter.
First step: Notice there is no condition linking S and P, so every student is paired with every Performance row having Marks > 84; then count the distinct student names that remain.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Relational model: relational algebra, tuple calculus and SQL
Every PYQ on this topic →Share this question
Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. Question paper · Answer key
More Databases PYQs
- 2026 Session 1 · Q30Which functional dependency inferences always hold
- 2026 Session 1 · Q31Dependency-preserving decompositions for 1NF, 2NF, 3NF, BCNF
- 2026 Session 1 · Q43Relational algebra equivalent of a tuple calculus join query
- 2026 Session 1 · Q65Number of superkeys with candidate keys {A,B} and {A,C}
- 2026 Session 2 · Q15Match DBMS schema levels with what they describe
- 2026 Session 2 · Q20When two transactions do not conflict on a data item