1 Answers
Option 3 : employees in the company.
Answer: Option 3
Explanation:
(select avg(salary) from emp)
This part of the Query will get evaluated first and gives " Average Salary of all employees in the company."
select deptId, count(⋆)
from emp
where gender = "female" and salary > (select avg(salary) from emp)
group by deptId;
this will count for each department no of employees who are female and whose salary is greater than the average salary.
Lets take an example
|
Empid |
Name |
Gender |
Salary |
deptid |
|
1 |
A |
Male |
2000 |
CSE |
|
2 |
B |
Female |
3000 |
CSE |
|
3 |
C |
Male |
4000 |
CSE |
|
4 |
D |
Female |
5000 |
CSE |
|
5 |
E |
Male |
3000 |
ME |
|
6 |
F |
Female |
4000 |
ME |
|
7 |
G |
Male |
4000 |
ME |
|
8 |
H |
Female |
2000 |
ME |
|
9 |
I |
Male |
1000 |
CE |
|
10 |
J |
Female |
2000 |
CE |
|
11 |
K |
Male |
4000 |
CE |
|
12 |
L |
Female |
5000 |
CE |
|
13 |
M |
Male |
3000 |
EC |
|
14 |
N |
Female |
4000 |
EC |
|
15 |
O |
Female |
5000 |
EC |
(select avg(salary) from emp) this will return 3400 as the average salary.
and final Query result will be
|
Deptid |
count |
|
CSE |
1 |
|
ME |
1 |
|
CE |
1 |
|
EC |
2 |