Question
Consider the following relational schema where 'did' and 'eid' are keys: dept(did:integer, dname:string, budget:real, managerid:integer) emp(eid:integer, ename:string, age:integer, salary:real) works(eid:integer, did:integer, pc time:integer) Write the
Consider the following relational schema where 'did' and 'eid' are keys:
dept(did:integer, dname:string, budget:real, managerid:integer)
emp(eid:integer, ename:string, age:integer, salary:real)
works(eid:integer, did:integer, pc time:integer)
Write the SQl query that:
a) Print the names of every employee who works in Hardware, Software, and Research departments.
b) Print the enames of managers who manage the departments with the largest budget.
c) Print the name of every department and the average salary of the employees of that department. The department must have a budget more than or equal to $50.
c) Print the managerids of managers who control the largest amount of total budget. As an example, if a manager manages two departments, the amount of total budget for him will be the sum of budgets of two departments. We want to find managers that have max total budget.
d) Print the name of every employee whose salary is less than or equal to the average salary of all employees in his/her departments
e) Print the name of every employee who works only in Hardware department.
Example of dept:
Example of emp:
Example of works:
did dname budget managerid 3 Software 1439119 110183 4 Human Resources 1174402 110303 5 5 Research 1544653 110511 6 Business Development 0 110303 8 Hardware 4291505 111692 9 9 Customer Service 1308515 111692 eid ename age salary 10042 Magy Stamatiou 60 81662 10059 Alejandro McAlpine 63 71218 10073 Shir McClurg 62 56473 12000 Alex Dalas 55 54000 12010 Sergio Ravarez 55 64000 12020 Antonio Lavante 34 36000 12030 Tonny Conner 25 44000 12100 Gladys Cooper 32 77000 12110 Rodney Ferreri 37 99000 110183 Shirish Ossenbruggen 63 48291 110303 Krassimir Wegerle 60 1374402 110511 DeForest Hagimont 59 48626 111400 Arie Staelin 57 72446 111692 Tonny Butterworth 40000 403353 Shigehito Kropatsch 52 59783 499868 Shaz Bierbaum 60 61802 499950 Weidon Gente 52 54788 499998 Patricia Breugel 60 40000 62 eid did pct_time 12000 8 100 120108 50 120208 90 12030 8 80 121008 100 12110 8 77 110183 3 70 110183 5 15 110183 8 15 110303 4 11 110303 5 17 110511 5 19 111400 8 45 1116929 100 403353 4 10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started