IAE Academy

GATE 2025 CS1 Q.55: solution and answer

GATE 2025 · CS1Q.55 · 2 marks · NAT

Consider the following database tables of a sports league.

player(pid,pname,age)
coach(cid,cname)
team(tid,tname,city,cid)
members(pid,tid)

An instance of the table and an SQL query are given.

player: (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30)
coach: (101, Ricky), (102, Mark), (103, Trevor)
team: (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103)
members: (1, 10), (2, 30), (3, 10), (4, 20)

SELECT MIN(P.age)
FROM player P
WHERE P.pid IN (
    SELECT M.pid
    FROM team T, coach C, members M
    WHERE C.cname = 'Mark'
        AND T.cid = C.cid
        AND M.tid = T.tid
)

The value returned by the given SQL query is ______ . (Answer in integer)

GATE 2025 CS1 question 55: Four tables side by side.Tap to open full size
Figure from the GATE 2025 CS1 paper. It is part of the question.
Figure description

Four tables side by side. player(pid, pname, age): rows (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30). coach(cid, cname): rows (101, Ricky), (102, Mark), (103, Trevor). team(tid, tname, city, cid): rows (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103). members(pid, tid): rows (1, 10), (2, 30), (3, 10), (4, 20).

Answer and solution

ANSWER

The query returns 26.

Official answer: 26Source: Official answer key, GATE 2025 CS1 (IIT Roorkee)

  1. Run the inner subquery first. The condition C.cname = 'Mark' keeps only the coach row , so .

  2. Join with team on T.cid = C.cid. Only the team row matches, so .

  3. Join with members on M.tid = T.tid. The members rows with are and .

  4. The subquery therefore returns .

  5. The outer query keeps the player rows with pid IN (1, 3): Jasprit (age 31) and Ishan (age 26).

KEY IDEA

Work out the IN subquery as a set of pids first (coach Mark, then his team, then the team's members). Then take the minimum age over only those players.

WATCH OUT FOR

Taking MIN over all players (24) or over Mark's team's whole roster by mistake. Another slip is to include the player from a different team, such as pid 2, who is on team 30 coached by Trevor. The subquery returns only pids 1 and 3.

From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 10 SQL questions, with notes

More SQL questions