oracle11g - sql subqueries and group by -


i'm having assignment sql class can't seem figure out. description of select wanted:

show employees of salary higher average of colleagues in department, departments @ least 4 employees.

i've been able find parts of query like

select ename    emp  sal > (select avg(sal)                      emp                    group                           deptno); 

to names of employees earn more avg.

or

select count(deptno)    emp group         deptno having count(deptno) > 4; 

to getthe number of employees in each department.

but somehow doesn't work linking them together. maybe can me shine light on on.

just put second query in , clause:

select ename    emp  sal > (select avg(sal)                      emp                    group                           deptno) , deptno in (select deptno                emp                group                 deptno having count(deptno) > 4); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -