Yurttas/PL/DBL/mysql-f-2010/01/PC/q10.sql

 1/*
 2REM
 3REM q10.sql
 4REM
 5REM Find the maker of the printer with the fastest processor
 6REM among all those PC's that have the smallest amount of RAM.
 7REM
 8*/
 9
10\. set-db.sql
11
12CREATE VIEW SmallRam(model,ram)
13  AS (SELECT model, ram
14      FROM PC
15      WHERE ram IN (SELECT MIN(ram)
16                    FROM  PC));
17
18SELECT P.maker
19FROM Product P, PC C, SmallRam S
20WHERE P.model=C.model
21  AND C.model=S.model
22  AND C.speed IN (SELECT MAX(speed)
23                  FROM PC, SmallRam S
24                  WHERE PC.model= S.model);