GateAI
SQL

GATE CSE 2015 Set 1 · Q27

NAT2 marksEasy

Time

Consider the following relations: 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 ____________.

GATE CSE 2015 Set 1 Q27 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 2

SQL

To determine the number of rows returned by the query:

  1. Join Condition (S.Roll_No = P.Roll_No):

    • Roll_No = 1 (Raj) joins with two rows in Performance: (1, Math, 80) and (1, English, 70).

    • Roll_No = 2 (Rohit) joins with two rows in Performance: (2, Math, 75) and (2, Physics, 65).

    • Roll_No = 3 (Raj) joins with two rows in Performance: (3, English, 80) and (3, Math, 80).

  2. Grouping by S.Student_Name:

    • The joined tuples contain only two distinct student names: 'Raj' and 'Rohit'.

    • The group for 'Raj' aggregates the marks for both Roll No 1 and Roll No 3, yielding a sum of 80+70+80+80=31080 + 70 + 80 + 80 = 310.

    • The group for 'Rohit' aggregates the marks for Roll No 2, yielding a sum of 75+65=14075 + 65 = 140.

  3. Result:

    • The output of the GROUP BY query contains one row per distinct Student_Name.

    • Therefore, the number of rows returned is 2.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This SQL previous year question is Q27 of the GATE CSE 2015 Set 1 paper. Find more GATE CSE PYQs on SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

SQL in GATE CSE

SQL has 17 GATE CSE PYQs across 14 papers from 2011 to 2025. 5 of them are 2-mark NAT questions like this one, and GATE CSE 2015 Set 1 has 2.

How GATE tests SQL

More from GATE CSE 2015 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2015 Set 1 · Q27 · NAT

Consider the following relations: Consider the following SQL query. SELECT S.StudentName, sum(P.Marks) FROM Student S, Performance P WHERE S.RollNo = P.RollNo GROUP BY S.StudentName The number of rows that will be returned by the SQL query is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.