Question: Consider the following two relational tables Table 1 : id , name,age,city,salary 1 , John, 2 8 , New York, 6 0 0 0 0

Consider the following two relational tables
Table 1:
id,name,age,city,salary
1,John,28,New York,60000
2,Alice,25,San Francisco,75000
3,Bob,32,Los Angeles,80000
4,Emma,29,Chicago,70000
5,James,35,Houston,90000
6,Sophia,26,Phoenix,65000
7,Michael,31,Philadelphia,85000
8,Olivia,27,San Antonio,72000
9,William,30,Dallas,88000
10,Ella,33,San Diego,95000
11,Liam,28,San Jose,78000
12,Ava,34,Austin,82000
13,Logan,29,Indianapolis,67000
14,Mia,32,Jacksonville,91000
15,Mason,26,San Francisco,80000
16,Isabella,31,San Diego,84000
17,Oliver,27,New York,72000
18,Sophie,29,Chicago,69000
19,Ethan,35,Los Angeles,92000
20,Amelia,30,Houston,77000
21,Jackson,28,Phoenix,87000
22,Charlotte,33,Philadelphia,78000
23,Aiden,25,San Antonio,72000
24,Lily,32,Dallas,89000
25,Lucas,29,San Jose,95000
26,Evelyn,34,Austin,85000
27,Aiden,31,Indianapolis,70000
28,Aria,26,Jacksonville,92000
29,Jack,35,Los Angeles,89000
30,Sofia,27,New York,76000
Table 2:
id,employee_id,department_name,manager,salary_budget
1,1,Marketing,John,100000
2,2,IT,Alice,120000
3,3,Finance,Bob,110000
4,4,Human Resources,Emma,95000
5,5,Operations,James,130000
6,6,Marketing,Sophia,105000
7,7,IT,Michael,125000
8,8,Finance,Olivia,115000
9,9,Human Resources,William,98000
10,10,Operations,Ella,135000
11,11,Marketing,Liam,108000
12,12,IT,Ava,118000
13,13,Finance,Logan,107000
14,14,Human Resources,Mia,94000
15,15,Operations,Mason,128000
16,16,Marketing,Isabella,103000
17,17,IT,Oliver,122000
18,18,Finance,Sophie,112000
19,19,Human Resources,Ethan,97000
20,20,Operations,Amelia,133000
21,21,Marketing,Jackson,106000
22,22,IT,Charlotte,116000
23,23,Finance,Aiden,105000
24,24,Human Resources,Lily,93000
25,25,Operations,Lucas,132000
26,26,Marketing,Evelyn,109000
27,27,IT,Aiden,121000
28,28,Finance,Aria,110000
29,29,Human Resources,Jack,96000
30,30,Operations,Sofia,134000
----------
Your task is to complete the following 10 queries
Query 1: Simple Selection
Retrieve the names and ages of employees in the "Marketing" department.
Query 2: Aggregation
Calculate the average salary for employees in each department.
Query 3: Subquery
Find employees whose salary is above the average salary in their department.
Query 4: Join and Order
List employees in the "IT" department ordered by salary in descending order.
Query 5: Aggregate and Filtering
Determine the total salary budget for the "Finance" department.
Query 6: Join and Conditional Aggregation
Show the maximum salary for each department.
Query 7: Subquery with NOT IN
Find employees who have not been assigned to any department.
Query 8: Window Function
Rank employees within their department based on salary.
Query 9: Self-Join
List employees and their managers.
Query 10: Common Table Expression (CTE)
Retrieve the top 3 highest-paid employees in each department.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!