GATE CS 2021 Set 2 | Question 41
Databases › SQL Queries · MCQ · 2 marks · Answer: B
- Question 41Databasesmcq2 marksThe relation scheme stores employee information, where
empIdis the key anddeptIdis the department to which the employee is assigned. Each employee is assigned to exactly one department.
Consider the SQL query:emp(empId, name, gender, salary, deptId)The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of:select deptId, count(*) from emp where gender = "female" and salary > (select avg(salary) from emp) group by deptId;- A.employees in the department.
- B.employees in the company.✓
- C.female employees in the department.
- D.female employees in the company.
Answer: B
Solution
The subquery(select avg(salary) from emp)is uncorrelated and computes the average salary over all employees in the company, so the comparison is against the company-wide average. - A.
More GATE PYQ on SQL Queries
All GATE CS Databases PYQ →Attempt GATE CS 2021 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →