in Databases
416 views
0 votes
0 votes

in Databases
416 views

1 comment

select emp_name

from EMP as EMP1

where salary > ( select avg(salary)

                         from EMP as EMP2 );
0
0

1 Answer

0 votes
0 votes

Sql query will be:

Select emp_name from Emp E1(Select dept_name,AVG(Salary) as A from Emp  E2 Group by(dept_name)) 

where E1.salary>E2.A and E1.dept_name=E2.dept_name.

edited by

2 Comments

in the where clause, it should be E1.dept_name=E2.dept_name, as table E2 has only two attributes, dept_name and A.
0
0
Yaa..got it.Thanks :)
0
0

Related questions