EMPLOYEE (fname, minit, lname, ssn, birthdate, address, sex, salary, superssn, dno)
KEY: ssn
DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate)
KEY: dnumber.
PROJECT (pname, pnumber, plocation, dnum)
KEY: pnumber.
WORKS_ON (essn, pno, hours)
KEY: (essn, pno)
DEPENDENT (essn, dependent-name, sex, bdate, relationship)
KEY: (essn, dependent-name)
I want to find first and last name and SSN of the unmarried managers who work on 4 or more projects in chicago.
This is what I have so far:
SELECT e.lname, e.ssn
FROM employee e, department d
wher (d.mgrssn = e.ssn)
and e.ssn in (
select w.essn
from works_on w, project p
where (w.pno = p.pnumber)
and p.plocation = 'cleveland'
group by w.essn
having count(*) >= 4
)
AND e.ssn NOT in (
select essn
from dependent
where relationship = 'Spouse'
);
- do I need a parenthesis when join d.mgrssn = e.ssn and where (w.pno = p.pnumber)
- I think my e.ssn not in clause is not correct?
Anyways feel free to corect my commands