Yurttas/PL/DBL/postgres/F/01/Bank/q110.sql

 1/*
 2REM
 3REM q110.sql
 4REM
 5REM Find all customers who have an account at all branches
 6REM located in 'Brooklyn'.
 7REM
 8*/
 9
10SELECT current_schema();
11SET search_path to "bank";
12
13SELECT DISTINCT S.customername
14FROM Depositor S
15WHERE NOT EXISTS 
16  (SELECT branchname
17   FROM Branch
18   WHERE branchcity = 'Brooklyn'
19     AND branchname NOT IN (SELECT T.branchname
20                            FROM Depositor T
21                            WHERE S.customername = T.customername));