GATE DA 2026 Q51: SQL query for each employee's team size
- Database Management and Warehousing
- 2 marks
- MSQ
- No negative marking
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.
| EmpID | TeamID |
|---|---|
| 1 | 8 |
| 2 | 8 |
| 3 | 8 |
| 4 | 7 |
| 5 | 7 |
| 6 | 9 |
| EmpID | TeamSize |
|---|---|
| 1 | 3 |
| 2 | 3 |
| 3 | 3 |
| 4 | 2 |
| 5 | 2 |
| 6 | 1 |
Which of the following is/are correct?
Try it: multiple select: one or more correct options
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
Source: official GATE 2026 DA question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Database Management and Warehousing PYQs
- 2026 · Q17Candidate keys from functional dependencies
- 2026 · Q18OLAP operation from Country to State
- 2026 · Q26Operations that never violate a foreign key
- 2026 · Q32Order of a B+ tree non-leaf node
- 2026 · Q41B+ tree root after inserting 3
- 2026 · Q42Output of a relational algebra expression with natural joins