GateAI
SQL

GATE CSE 2016 Set 2 · Q52

NAT2 marksMedium

Time

Consider the following database table named water_schemeswater\_schemes : The number of tuples returned by the following SQL query is _______ .with total(name, capacity) as select district_name, sum(capacity) from water_schemes group by district_name with total_avg(capacity) as select avg(capacity) from total select name from total, total_avg where total.capacity ≥ total_avg.capacity

GATE CSE 2016 Set 2 Q52 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 2 (±0)

SQL

To determine the number of tuples returned by the query, let us evaluate the query step by step:

  1. First CTE (total): Groups by district_name and calculates the total capacity for each district:

    • Ajmer: 2020

    • Bikaner: 10+10+20=4010 + 10 + 20 = 40

    • Churu: 10+20=3010 + 20 = 30

    • Dungargarh: 1010

  2. Second CTE (total_avg): Calculates the average of the aggregated capacities in total:

    Average capacity=20+40+30+104=1004=25\text{Average capacity} = \frac{20 + 40 + 30 + 10}{4} = \frac{100}{4} = 25
  3. Main Query: Selects the name from total where total.capacity ≥25\ge 25:

    • Bikaner (40≥2540 \ge 25): satisfies the condition

    • Churu (30≥2530 \ge 25): satisfies the condition

    • Ajmer (20<2520 < 25): does not satisfy

    • Dungargarh (10<2510 < 25): does not satisfy

Thus, 2 tuples (Bikaner, Churu) are returned.

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 Q52 of the GATE CSE 2016 Set 2 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 it is the only one in GATE CSE 2016 Set 2.

How GATE tests SQL

More from GATE CSE 2016 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2016 Set 2 · Q52 · NAT

Consider the following database table named water\schemes : The number of tuples returned by the following SQL query is … with total(name, capacity) as select districtname, sum(capacity) from waterschemes group by districtname with totalavg(capacity) as select avg(capacity) from total select name from total, totalavg where total.capacity ≥ totalavg.capacity

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.