Consider the following relations and answer questions 16 usi
Consider the following relations and answer questions 1-6 using SQL.
Emp (eno, ename, title, city) eno is the primary key
Proj (pno, pname, budget, city) pno is the primary key
Works (eno, pno, responsibility, duration) eno and pno are both primary key
Pay (title, salary) title is primary key
Find the enames of employees who work on the project named “Installation”.
Find the employees’ number whose salaries are above the average salary.
For each city, how many projects are located in that city and what is the total budget over all projects in the city?
Find the names of projects whose budgets are greater than the budgets of any projects located in “Boca Raton”.
Find employees’ enames who work on all the projects.
Find projects’ names for any project if there are more than 2 people sharing the same responsibility.
Solution
1.select ename from enp e,works w,proj p
where e.eno=w.eno and p.pno=w.pno
2.
3.select city,sum(budget),count(*) from from proj
group by city
4.select pname,budget from proj
group by budget having budget>(select sum(budget) from proj where loc=\'Boca Raton\')
5.select ename from emp e,proj p,works w
where e.eno=p.pno and p.pno=w.pno
6.
