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 :
idname,age,city,salary
John,New York,
Alice,San Francisco,
Bob,Los Angeles,
Emma,Chicago,
James,Houston,
Sophia,Phoenix,
Michael,Philadelphia,
Olivia,San Antonio,
William,Dallas,
Ella,San Diego,
Liam,San Jose,
Ava,Austin,
Logan,Indianapolis,
Mia,Jacksonville,
Mason,San Francisco,
Isabella,San Diego,
Oliver,New York,
Sophie,Chicago,
Ethan,Los Angeles,
Amelia,Houston,
Jackson,Phoenix,
Charlotte,Philadelphia,
Aiden,San Antonio,
Lily,Dallas,
Lucas,San Jose,
Evelyn,Austin,
Aiden,Indianapolis,
Aria,Jacksonville,
Jack,Los Angeles,
Sofia,New York,
Table :
idemployeeiddepartmentname,manager,salarybudget
Marketing,John,
ITAlice,
Finance,Bob,
Human Resources,Emma,
Operations,James,
Marketing,Sophia,
ITMichael,
Finance,Olivia,
Human Resources,William,
Operations,Ella,
Marketing,Liam,
ITAva,
Finance,Logan,
Human Resources,Mia,
Operations,Mason,
Marketing,Isabella,
ITOliver,
Finance,Sophie,
Human Resources,Ethan,
Operations,Amelia,
Marketing,Jackson,
ITCharlotte,
Finance,Aiden,
Human Resources,Lily,
Operations,Lucas,
Marketing,Evelyn,
ITAiden,
Finance,Aria,
Human Resources,Jack,
Operations,Sofia,
Your task is to complete the following queries
Query : Simple Selection
Retrieve the names and ages of employees in the "Marketing" department.
Query : Aggregation
Calculate the average salary for employees in each department.
Query : Subquery
Find employees whose salary is above the average salary in their department.
Query : Join and Order
List employees in the IT department ordered by salary in descending order.
Query : Aggregate and Filtering
Determine the total salary budget for the "Finance" department.
Query : Join and Conditional Aggregation
Show the maximum salary for each department.
Query : Subquery with NOT IN
Find employees who have not been assigned to any department.
Query : Window Function
Rank employees within their department based on salary.
Query : SelfJoin
List employees and their managers.
Query : Common Table Expression CTE
Retrieve the top highestpaid employees in each department.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
