Consider a database that has the relation schema EMP (EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below. The output of executing the SQL query is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 1 · Q23
Time


Your answerNumerical answer
Solution
Official answer: 2.6 (±0)
Relational Model and SQLLet us analyze the query and the data:
The subquery groups the relation EMP by DeptName and counts the number of employees in each department:
Department AA: employees (EmpId 1, 2, 3, 4)
Department AB: employees (EmpId 5, 6, 7)
Department AC: employees (EmpId 8, 9, 10)
Department AD: employees (EmpId 11, 12)
Department AE: employee (EmpId 13)
The subquery returns the pairs: (AA, 4), (AB, 3), (AC, 3), (AD, 2), (AE, 1).
The outer query computes the average of Num across all departments selected:
Thus, the output of the query is 2.6.
Try the question first, then check your work.
Examiner trap
Group the table by DeptName, count the employees in each department, and then calculate the average of these department counts.
This Relational Model and SQL previous year question is Q23 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Relational Model and SQL in Databases, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Relational Model and SQL PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Relational Model and SQL has 15 GATE CSE PYQs across 12 papers from 2011 to 2026. 2 of them are 1-mark NAT questions like this one, and GATE CSE 2017 Set 1 has 3.
How GATE tests Relational Model and SQLIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.