GateAI
Relational Model and SQL

GATE CSE 2017 Set 2 · Q46

NAT2 marksMedium

Time

Consider the following database table named top_scorer. Consider the following SQL query:SELECT ta.player FROM top_scorer AS ta WHERE ta.goals >ALL (SELECT tb.goals FROM top_scorer AS tb WHERE tb.country = 'Spain') AND ta.goals >ANY (SELECT tc.goals FROM top_scorer AS tc WHERE tc.country = 'Germany')The number of tuples returned by the above SQL query is ________.

GATE CSE 2017 Set 2 Q46 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 7 (±0)

Relational Model and SQL

Let us evaluate the two conditions in the WHERE clause:

  1. First condition:ta.goals >ALL (SELECT tb.goals FROM top_scorer AS tb WHERE tb.country = 'Spain')

    • There are no players with country = 'Spain' in the top_scorer table.

    • The subquery returns an empty set ∅\emptyset.

    • In SQL, > ALL (empty set) evaluates to TRUE for all rows.

  2. Second condition:ta.goals >ANY (SELECT tc.goals FROM top_scorer AS tc WHERE tc.country = 'Germany')

    • The subquery returns the goals scored by players from Germany: {16,14,11,10,10}\{16, 14, 11, 10, 10\}.

    • > ANY evaluates to TRUE if ta.goals is strictly greater than at least one element in the set, which means ta.goals > min({16, 14, 11, 10, 10}) = 10.

    • Thus, the condition simplifies to ta.goals > 10.

  3. Matching tuples: We count the players with goals > 10:

    • Klose (1616)

    • Ronaldo (1515)

    • G Müller (1414)

    • Fontaine (1313)

    • Pelé (1212)

    • Klinsmann (1111)

    • Kocsis (1111)

There are a total of 7 such tuples.

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 Relational Model and SQL previous year question is Q46 of the GATE CSE 2017 Set 2 paper. Find more GATE CSE PYQs on Relational Model and 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 Relational Model and 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.

Relational Model and SQL in GATE CSE

Relational Model and SQL has 15 GATE CSE PYQs across 12 papers from 2011 to 2026. 2 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2017 Set 2.

How GATE tests Relational Model and SQL

More from GATE CSE 2017 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2017 Set 2 · Q46 · NAT

Consider the following database table named topscorer . Consider the following SQL query: SELECT ta.player FROM topscorer AS ta WHERE ta.goals >ALL (SELECT tb.goals FROM topscorer AS tb WHERE tb.country = 'Spain') AND ta.goals >ANY (SELECT tc.goals FROM topscorer AS tc WHERE tc.country = 'Germany') The number of tuples returned by the above 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.