Yurttas/PL/DBL/postgres/F/01/Company-B/q05.sql

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2REM
 3REM q05.sql
 4REM
 5REM Find all employees who live in the same City and
 6REM on the same Street as their Manager.
 7REM
 8*/
 9
10SELECT current_schema();
11SET search_path to "companyb";
12
13SELECT E1.employeename 
14FROM Employee E1, Manages M, Employee E2 
15WHERE E1.employeename = M.employeename 
16  AND M.managername = E2.employeename 
17  AND E1.Street = E2.Street 
18  AND E1.City = E2.City;