SQL-Obtain code of the employees who participated in all projects

Asked

Viewed 23 times

0

I have the following tables Employee(Empnum ,Name) Project(Projnum,Name) and Assignment (Empnum ,Projnum,Function)

I wanted to build a query in which I return the employee number (Empnum ) that through the Assignment participated in all the Projects. I tried to do something like:

Select A.ProjNum
From Atribuicao A
Where A.EmpNum in (Select E.EmpNum From Empregado E)

But it’s insufficient... and I’m not getting the result.

  • Search by division in relational Lgebra , simplifying a not exists in another not exists , classic solution , I had an example , I lost.

1 answer

1


What Motta suggested was:

SELECT E.Nome
FROM Empregado E
WHERE NOT EXISTS (SELECT P ProjNum
                  FROM Project P
                  WHERE NOT EXISTS (SELECT A.ProjNum
                                    FROM Atribuicao A
                                    WHERE A.ProjNum = P.ProjNum
                                    AND A.EmpNum = E.EmpNum)) 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.