Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following relations: Emp (id, name, age, salary) Dept (did, name, s

ID: 3591559 • Letter: C

Question

Consider the following relations: Emp (id, name, age, salary) Dept (did, name, street, city, budget, managerid) Works (eid, did, pct_time) *eid stands for employee id Write the following queries in SQL. No duplicates should be printed in any of the answers. a. Find the names of employees who have not worked in ‘Education’ department. b. Find the names of all employees working in a department managed by ‘Gates’. c. Find the age of the oldest employee who has either worked part time (pct_time < 100) or having a salary more than 35,000. d. Find the names of employees who have worked in two departments located in the same city. e. For each level of age group, display the level and average salary of employees for that level. f. Find the names of employees who have worked in all departments.

Explanation / Answer

a)

select distinct e.name from emp as e

inner join works as w

on e.id =w.eid

inner join dept as d

on d.did=w.did and d.name!="Eduecation"

b)

select distict e.name from emp e

inner join works w

on e.id =w.eid

inner join dept d

on d.did=w.did and d.name!="Gates";

c)select distinct e.max(age) from emp e

inner join works w

on e.id = w.eid

and w.pct_time <100 or e.salary >35000

e) note:considering three levels of age group in this query.

f)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote