1 / 10

Query to Find Employees with Salary Greater Than Managers' Salary

This SQL query retrieves the names of employees whose salaries exceed those of their respective managers. It utilizes subqueries to determine the minimum or maximum salaries associated with managers in the departments. Furthermore, it identifies departments that have at least five employees earning more than $5,000, ensuring comprehensive salary comparisons across the workforce. The correct SQL query formats are provided to ensure accurate data retrieval and insights into employee compensation.

lynnea
Download Presentation

Query to Find Employees with Salary Greater Than Managers' Salary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Find the names of all employees whose salary greater than some manager’s salary .EMP(E#, Ename , Sal, D#, MGR#)DEPT(D#, Dname, MGR)

  2. 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’)

  3. 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

  4. Where (count(EMP. Sal >5000)>= 5) • Where having count (select sal >5000 from EMP)

  5. 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)

  6. select Ename From EMP Where Emp.Salary>some(select min(salary) from EMP where E# in (select mgr# from DEPT))

  7. 2. Find the names of all employeeswhose salary greater than all manager’s salary .

  8. 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)

  9. 3.Find all departments’ name which have at leastfive employees whose salary grater than $5000.

  10. Correct answer Select Dname From DEPT Where (select count(E#) from Emp where Emp.D#=Dept.D# and Emp.sal>5000)>=5;

More Related