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

From ZCubes Wiki
Revision as of 23:48, 4 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="sql" line start="1" enclose="div">/* REM REM q07.sql REM REM Find the manufacturer(s) of the computer(PC or laptop) REM with the highest available speed...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/*
 2REM
 3REM q07.sql
 4REM
 5REM Find the manufacturer(s) of the computer(PC or laptop)
 6REM with the highest available speed.
 7REM
 8*/
 9
10SELECT current_schema();
11SET search_path to "pc";
12
13CREATE VIEW ProdSpeed(model, speed)
14  AS (SELECT model, speed
15      FROM PC
16      WHERE speed IN (SELECT MAX(speed)
17                      FROM  PC))
18     UNION
19     (SELECT model, speed
20      FROM Laptop
21      WHERE speed IN (SELECT MAX(speed)
22                      FROM  Laptop));
23
24SELECT P.maker, S.speed
25FROM Product P, ProdSpeed S
26WHERE P.model=S.model
27  AND S.speed IN (SELECT MAX(speed)
28                  FROM ProdSpeed);