GATE DA 2026 Set 1 — Question 51
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MSQ+2 / -0MediumAggregate FunctionsSQLDatabase Management & WarehousingFiltering, Grouping & Nested QueriesJoins
Database Management & Warehousing → SQL → Aggregate Functions
Last updated
Question
Consider a table
Output
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.Which of the following is/are correct?Employee| 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 |
Correct answer
(A) [code]
Solution
We need to calculate the size of each team and then join it back to the employees to show the size for each employee.
- Option A: Correct. The subquery
Bcalculates the count (TeamSize) for eachTeamID. The outer query joins theEmployeetableEwithBonTeamID, correctly associating each employee with their team's size. - Option B: Incorrect. The condition
A.EmpID = B.EmpIDrestricts the join to only match the employee with themselves. The count will always be 1 for every employee. To be correct, it should beWHERE A.TeamID = B.TeamIDwithout theEmpIDequality check, or a proper self-join logic. - Option C: Incorrect.
GROUP BY EmpIDwill result in a count of 1 for each row (sinceEmpIDis the primary key), not the team size. - Option D: Incorrect. The subquery
SELECT COUNT(TeamID) AS TeamSize FROM Employee GROUP BY TeamIDreturns a list of counts but does not select theTeamIDcolumn. Therefore, the join conditionWHERE A.TeamID = B.TeamIDis invalid becauseBdoes not have aTeamIDcolumn.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE DA question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on SQL
2026 Set 1 Q17 be a relational schema with functional dependency set…2026 Set 1 Q18Consider that the visualization of a 3-dimensional data cube is showing Sales Quantity for each…2026 Set 1 Q26Consider two relations r and s defined on the relational schemas R(A,B) and S(E,C), respectively. A…2026 Set 1 Q32In a relational database, a B+ Tree Index is to be constructed for a relation on a key field. In a…2026 Set 1 Q41Consider a B+ Tree where the maximum number of key values in each leaf node is 2 and the maximum…