100 likes | 197 Views
Find the names of all employees whose salary greater than some manager ’ s salary . EMP(E#, Ename , Sal, D#, MGR#) DEPT(D#, Dname, MGR). Wrong answer:. Where E.sal > (select EMP.sal From EMP, DEPT where EMP.ename = DEPT.MGR)
E N D
Find the names of all employees whose salary greater than some manager’s salary .EMP(E#, Ename , Sal, D#, MGR#)DEPT(D#, Dname, MGR)
Wrong answer: • Where E.sal > (select EMP.sal From EMP, DEPT where EMP.ename = DEPT.MGR) • Select department From class where employee.sal > some managers.sal • Where (E.sal > sal from emp) • Where (e.sal > sal where mgr =”true’)
select Ename from emp wher EMp.sal> mgrsal • Forall empx.ename (salary > dept.sal) • Where sal > (select sal from manager where name =”someone”) • Select a.ename from EMP a,b Where forall b.sal (a.sal > b.sal) and a.mgr =0 and b.mgr =1
Where (count(EMP. Sal >5000)>= 5) • Where having count (select sal >5000 from EMP)
correct answer: select Ename From EMP Where Salary>(select min(salary) from EMP where E# in (select mgr from DEPT)) select Ename From EMP Where Salary>(select min(salary) from EMP,DEPT where EMP.E#=DEPT.mgr)
select Ename From EMP Where Emp.Salary>some(select min(salary) from EMP where E# in (select mgr# from DEPT))
2. Find the names of all employeeswhose salary greater than all manager’s salary .
correct answer: select Ename From EMP Where Salary>(select max(salary) from EMP where E# in (select mgr from DEPT)) select Ename From EMP Where Salary>(select max(salary) from EMP,DEPT where EMP.E#=DEPT.mgr)
3.Find all departments’ name which have at leastfive employees whose salary grater than $5000.
Correct answer Select Dname From DEPT Where (select count(E#) from Emp where Emp.D#=Dept.D# and Emp.sal>5000)>=5;