Skip to content
GATEiit

GATE DA 2026 Q51: SQL query for each employee's team size

Question

Consider a table Employee(EmpID, TeamID), where the column EmpID (ID of an employee) is the primary key. The column TeamID denotes the team ID of the team of which the employee is a member. TeamID is a NOT NULL column.

We want to display the size of the team (denoted as TeamSize) in which each employee is a member by using SQL. As an example, the desired output for the given Employee table is also shown in tabular form.

Employee
EmpIDTeamID
18
28
38
47
57
69
Output
EmpIDTeamSize
13
23
33
42
52
61

Which of the following is/are correct?

Try it: multiple select: one or more correct options

Select one or more options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation

Answer: A (official GATE 2026 final answer key)

Concept used: Compute team sizes with GROUP BY TeamID, then join back to employees on TeamID.

First step: B joins each employee only with itself (count 1); C groups by the unique EmpID (count 1); D's subquery has no TeamID column to join on.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2026 DA question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key