Quantcast
Channel: Selecting ALL from a specific range - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Selecting ALL from a specific range

$
0
0

I have the following question:

Find the names of employees who work on all the projects controlled by department number 5.

The tables I have are Employees (SSN), Works_On(SSN, PNumber), Projects(PNumber, DNumber).

I'm trying to figure out the "ALL" part. I tried different methods, but the thing I'm trying to do is create a canonical query tree, so I need to make sure the SQL query can be converted into that.

I've tried the following:

SELECT E.Fname, E.LnameFROM Employee AS E, works_on AS WWHERE E.SSN IN ALL(SELECT SSNFROM Projects AS PWHERE W.SSN = E.SSN AND W.PNUMBER = P.PNUMBER AND P.DNUMBER = 5);

But I'm unsure it will work since I used IN ALL. One more thing I tried is getting the count of the works on and group by employee, and getting the count of the projects.

Eventually I found this:

select fname, lnamefrom employeewhere not exists ( (select pnumber from project where dnum = 5)                   MINUS                    (select pno from works_on where essn = ssn)                 );

But I wasn't able to convert it into a tree.

Do you have any suggestions that I might use? And yes it's Homework.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images