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

From ZCubes Wiki
Revision as of 00:37, 5 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="sql" line start="1" enclose="div">/* REM REM a04.sql REM REM Find the average balance of all depositors REM who live in Harrison and have at least 3 acc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/*
 2REM
 3REM a04.sql
 4REM
 5REM Find the average balance of all depositors
 6REM who live in Harrison and have at least 3 accounts.
 7REM
 8*/
 9 
10SELECT current_schema();
11SET search_path to "bank";
12
13SELECT AVG(balance)
14FROM Depositor, Customer
15WHERE Depositor.customername = Customer.customername
16  AND Customer.customercity = 'Harrison'
17GROUP BY Depositor.customername
18HAVING COUNT(accountnumber) >= 3;