Yurttas/PL/DBL/mysql/F/01/00/SPJ/q07.sql

 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
11\. set-db.sql
12
13SELECT DISTINCT jn
14FROM Shipments
15WHERE pn = 'P1'
16GROUP BY jn
17HAVING AVG(quantity) > (SELECT MAX(quantity)
18                        FROM Shipments
19                        WHERE jn='J01');