GATE CS 2019 Set 1 — Question 61
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.NAT+2 / -0MediumSQL JoinsSQLDatabasesGrouping & OrderingAggregate Functions
Databases → SQL → Aggregate Functions
Last updated
Question
A relational database contains two tables Student and Performance as shown below:Student
Performance
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 below:The number of rows returned by the above SQL query is ________.
| 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;
Correct answer
5 to 5
Solution
The SQL query performs a Cartesian product (cross join) between the
Student table and the Performance table because there is no join condition (e.g., S.Roll_no = P.Roll_no) specified in the WHERE clause.1.Filter Performance Table: The condition
WHERE P.Marks > 84 filters the Performance table. The rows with marks 86, 95, 90, 89, and 92 satisfy this. There are 5 such rows.2.Cross Join: The
FROM Student S, Performance P clause with the filter results in a cross join between all 5 rows of the Student table and the 5 filtered rows of the Performance table. This results in intermediate rows.3.Grouping: The
GROUP BY S.Student_name clause groups these 25 rows by the student name. There are 5 distinct student names in the Student table: Amit, Priya, Vinit, Rohan, and Smita.4.Output: Each unique group (student name) produces exactly one row in the final result set, regardless of the sum calculation.
Therefore, the number of rows returned is 5.Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on SQL
2026 Set 2 Q15In the context of DBMS, consider the two sets T and S given below. | T | S | |---|---| | I:…2026 Set 2 Q20Consider concurrent execution of two transactions and in a DBMS, both of which access a…2026 Set 1 Q30Let and be the attributes of a relation in a relational schema. Let…2026 Set 1 Q31In the context of relational database normalization, which of the following statements is/are true?2026 Set 2 Q42In the context of schema normalization in relational DBMS, consider a set F of functional…