GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 55

Evaluating an SQL subquery and MIN aggregate

Database Management Systems · SQL & Queries · Full GATE CSE 2025 Set 1 paper

GATE 2025 Set 1, Q55 2 marks · NAT
Report issue

SQL & Queries

Question 55, GATE 2025: Tables: player(pid,pname,age) has (1,Jasprit,31),(2,Atharva,24),(3,Ishan,26),(4,Axar,30). coach(cid,cname) has (101,Ricky),(102,Mark),(103,Trevor). team(tid,tname,city,cid) has (10,MI,Mumbai,102),(20,DC,Delhi,101),(30,PK,Mohali,103). members(pid,tid) has (1,10),(2,30),(3,10),(4,20). Evaluate 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).
Tap to enlarge
Answer & solution

Official answer: 26

Approach: Evaluate the inner join and filter to get a set of player IDs, then apply the outer aggregate only to those players.
The condition C.cname='Mark' selects coach row cid=102. Joining on T.cid=C.cid selects team tid=10, because that is the team coached by 102. Joining membership on M.tid=T.tid then selects the rows (1,10) and (3,10), so the subquery returns player IDs {1,3}.
The outer WHERE P.pid IN (...) retains Jasprit, age 31, and Ishan, age 26. MIN over those two ages is 26, which is the returned value.
Atharva’s age 24 is smaller overall but belongs to team 30 coached by Trevor; the predicate removes that row before MIN is computed. Axar likewise belongs to team 20 coached by Ricky. This demonstrates why aggregating over the entire player table before applying the team/coach restriction would be incorrect.

Original paper, page 55 · Answer key