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

From ZCubes Wiki
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');