employee (Lastname, FirstName, MidInitial, gender, street, city) works (Lastname
ID: 3919122 • Letter: E
Question
employee (Lastname, FirstName, MidInitial, gender, street, city)
works (Lastname, FirstName, MidInitial, company_name, salary)
manages(Lastname, FirstName, MidInitial, ManagerLastname, MFirstName, MMidInitial, start-date)
Using the above tables answer the queries in SQL
Q10. Find the names of the companies which have employees residing in every city where employees of Mutual of Omaha live.
This means that if Mutual of Omaha has employees that live in 3 different cities (Omaha, Lincoln, Denver) the query finds companies which has employees in all of those cities.
I've posted this multiple times but every answer given to me so far has been wrong. Please read the question.
Explanation / Answer
SELECT COMPANY_NAME FROM EMPLOYEE E1,WORKS W1 WHERE E1.CITY IN (SELECT CITY FROM EMPLOYEE E2,WORKS W2 WHERE E2.FNAME=W2.FNAME AND E2.LNAME=W2.LNAME AND W1.COMPANY_NAME="MUTUAL_OF_OMAHA") AND E1.FNAME=W1.FNAME AND E1.LNAME=W1.LNAME
I executed this querie it is giving the correct output
If you have any doubt post a comment.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.