Yurttas/PL/DBL/postgres/F/01/SPJ/q07.sql

From ZCubes Wiki
Revision as of 00:54, 5 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="sql" line start="1" enclose="div">/* REM REM q07.sql REM REM Get project numbers for projects supplied with part 'P01' REM in an average quantity greate...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/*
 2REM
 3REM q07.sql
 4REM
 5REM Get project numbers for projects supplied with part 'P01'
 6REM in an average quantity greater than the greatest quantity
 7REM in which any part is supplied to project 'J01'.
 8REM
 9*/
10
11SELECT current_schema();
12SET search_path to "spj";
13
14SELECT DISTINCT jn
15FROM Shipments
16WHERE pn = 'P1'
17GROUP BY jn
18HAVING AVG(quantity) > (SELECT MAX(quantity)
19                        FROM Shipments
20                        WHERE jn='J01');