Yurttas/PL/DBL/mssql/F/01/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
11SELECT DISTINCT jn
12FROM Shipments
13WHERE pn = 'P1'
14GROUP BY jn
15HAVING AVG(quantity) > (SELECT MAX(quantity)
16 FROM Shipments
17 WHERE jn='J01');