Download presentation

Presentation is loading. Please wait.

Published byJovan Mollick Modified over 2 years ago

1
Classwork notes

2
2 Find the names of all employees whose salary greater than all managers salary.

3
3 select Ename from EMP where sal > all (select sal from EMP where E# in ( select mgr from DEPT)) select Ename from EMP where sal > (select max(sal) from EMP where E# in ( select mgr from DEPT))

4
4 select e.ename from e emp Where not exist (select d# from d dept Where d.mgrsal > e.sal); select ename from emp Where sal > sal Sal in (select max(sal) from mgr )

5
5 Select ename from emp where emp.sal > (select distinct sal from MNQ where MNG.sal = MAX(mng.sal))

6
6 select ename from emp Where sal > some (select sal from manager); select name from emp Where emp.sal > every (select sal from manager )

7
7 Find all departments name which have at least five employees whose salary grater than $5000.

8
8 Select dname From Dept Where dname in (select salary, count(distinct ename) From EMP where salary>5000 group by dept

9
9 Select dname From Dept, Emp Where (select count(*) From EMP where salary>5000 and dept.d#)>4

10
10 Select dname From Dept,Emp Where Dept.dname=Emp.ename AND (select count(dname) From Dept,Emp where Dept.dname=Emp.ename AND salary>5000)>5

11
11 Select d#, dname From Dept,Emp Where Dept.d#=Emp.d# AND (select num, count(dname) From Dept,Emp group by emp.d# having salary>5000)>=5

12
12 Select dname From Dept, Emp Where count (select * From Emp where salary>5000 AND d#=Emp.d#);

13
13 Select dept.dname from emp, dept Where dept.d#=emp.d# and emp.sal>5000 Group by dept.dname Having count(*) >=5 ;

14
14 Select d.dname From Dept d Where d.d# in (select e.d# From Emp e where e.sal>5000 Group by e.d# Having count(*)>5);

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google