GATE 2021 CS (CS2) – Question 41
emp(empId,name,gender,salary,deptId) has key empId, and each employee belongs to one department. What does this query count for each department?
SELECT deptId,COUNT(*) FROM emp
WHERE gender='female'
AND salary>(SELECT AVG(salary) FROM emp)
GROUP BY deptId;It counts female employees earning more than the average salary of whom?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (B) Employees in the company
Explanation
The subquery is uncorrelated and has neither department nor gender filtering, so it computes the company-wide average over all employees. The outer query filters women above that average and groups qualifying rows by department. Thus B; departments without qualifying rows do not appear.
More Relational Model: Relational Algebra, Tuple Calculus, SQL questions
- GATE 2026 CS (CS1) Q30
- GATE 2026 CS (CS1) Q43
- GATE 2025 CS (CS1) Q39
- GATE 2025 CS (CS1) Q55
- GATE 2025 CS (CS2) Q54
- GATE 2024 CS (CS1) Q35
All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →