GATE CS 2015 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 / -0MediumGrouping & OrderingSQLDatabasesAggregate FunctionsSQL Joins
Databases → SQL → Aggregate Functions
Last updated
Question
Consider the following relations:Student
Performance
Consider the following SQL query.The number of rows that will be returned by the SQL query is ___________.
| Roll No | Student_Name |
|---|---|
| 1 | Raj |
| 2 | Rohit |
| 3 | Raj |
| Roll No | Course | Marks |
|---|---|---|
| 1 | Math | 80 |
| 1 | English | 70 |
| 2 | Math | 75 |
| 3 | English | 80 |
| 2 | Physics | 65 |
| 3 | Math | 80 |
SELECT S.Student_Name, sum(P.Marks)
FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_Name
Correct answer
2 to 2
Solution
The SQL query joins the
Student and Performance tables on Roll_No and then groups the results by Student_Name.1.Join Step:
- Roll No 1 (Raj) matches with Math (80) and English (70).
- Roll No 2 (Rohit) matches with Math (75) and Physics (65).
- Roll No 3 (Raj) matches with English (80) and Math (80).
- The grouping is done on
Student_Name. - The distinct student names are "Raj" and "Rohit".
- All records for "Raj" (from both Roll No 1 and Roll No 3) are grouped together into a single group.
- All records for "Rohit" are grouped into a single group.
Student_Name values ("Raj" and "Rohit"), the query will return 2 rows.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…