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

From ZCubes Wiki
Revision as of 00:43, 5 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="sql" line start="1" enclose="div">/* REM REM q12.sql REM REM Find those companies that pay more, on average, REM than the average salary at 'First Bank ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/*
 2REM
 3REM q12.sql
 4REM
 5REM Find those companies that pay more, on average,
 6REM than the average salary at 'First Bank Corporation'.
 7REM
 8*/
 9
10SELECT current_schema();
11SET search_path to "companyb";
12
13SELECT companyname 
14FROM Works 
15GROUP BY companyname 
16HAVING AVG(salary) > (SELECT AVG(salary) 
17                      FROM Works 
18                      WHERE companyname='First Bank Corporation');