Retrieve the names of all employees in department 5
who work more than 10 hours per week on the
‘ProductX’ project.
p10ssn ← (Π essn (σ hours > 10 (works-on |X| pno =
pnumber(Π pnumber (σ pname = ‘ProductX’ (project))))
Π lname, minit, fname (σ dno = 5 (employee |X| ssn = essn
(p10ssn)))
select lname, minit, fname
from employee, works-on, project
where ssn = essn AND pno = pnumber AND
dno = 5 AND hours > 10 AND
pname = ‘Product X’;
List the names of all employees who have a dependent
with the same first name as themselves.
Π lname, minit, fname (employee |X| fname =
dependent-name AND ssn = essn (dependent))
select lname, minit, fname
from employee, dependent
where fname = dependent-name AND
ssn = essn;
Find the names of all employees who are directly
supervised by ‘Franklin Wong’.
Π lname, minit, fname (employee |X| superssn = ssn (Π ssn (σ
fname = ‘Franklin’ AND lname = ‘Wong’ (employee))))
select employee.lname, employee.minit, employee.fname
from employee emp
where emp.lname = ‘Wong’ AND
emp.fname = ‘Franklin’ AND
employee.superssn = emp.ssn;
For each project, list the project name and the total
hours per week (by all employees) spent on that
project.
pname F sum hours (project |X| pnumber = pno (works-on))
select pname, sum(hours)
from project, works-on
where pno = pnumber
group by pname;
For each department, retrieve the department name
and the average salary of all employees working in
that department.
dname F average salary (department |X| dnumber = dno
(Π dno, salary, ssn (employee)))
select dname, average(salary)
from department, employee
where dnumber = dno
group by dname;
Retrieve the average salary of all female employees.
F average salary (σ sex = ‘F’ (employee))
select average (salary)
from employee
where sex = ‘f’;