0% found this document useful (0 votes)
22 views2 pages

Sub Query Ex

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Sub Query Ex

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Employee

emp_id emp_name dept_id manager_id salary

101 Alice 10 NULL 80000

102 Bob 20 101 60000

103 Charlie 10 101 55000

104 David 30 102 50000

105 Emma 20 102 65000

106 Frank 40 101 70000

Department

dept_id dept_name location

10 HR New York

20 IT Chicago

30 Finance Dallas

40 Marketing Miami

50 Operations Denver
Project

proj_id proj_name dept_id budget

201 Payroll Sys 30 200000

202 Website Revamp 20 150000

203 Hiring Drive 10 100000

204 Ad Campaign 40 180000

205 Supply Chain 50 220000

1. Display employees whose salary is higher than the average salary of all employees.
2. Find employees who work in departments located in Chicago (using a subquery).
3. List employees who earn more than Frank’s salary.
4. Show the project(s) with the highest budget (using subquery).
5. Display the employee(s) who has the same salary as Emma.
6. Find the department where the highest-paid employee works.
7. Show the employee(s) with the lowest salary in the company.
8. Display the project whose budget is equal to the budget of the Payroll Sys project.
9. List employees who work in the same department(s) as Frank or Emma.
10. Display projects that are handled by the departments of employees earning more
than 65,000.
11. Find employees who earn a salary equal to any salary in department 20.
12. Show employees whose salary is greater than all employees in department 30.
13. Display employees who earn the maximum salary in their department.
14. Find employees whose salary is above the average salary of their department.
15. List departments where no employee earns more than 60,000.
16. Show projects that have a budget greater than the total salary of employees in that
project’s department.
17. Find employees who work in a department where at least one project has a budget
greater than 200,000.
18. List the employees who earn more than the average salary of employees in the IT
department.
19. Display the department(s) where the highest-paid employee works, and then list all
employees from those departments.
20. Find projects handled by departments that have no employees.

You might also like