Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / Databases / Practice01.sql
blob: dab5131ce7972bd8c7984f3226a182ba8bed85f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- MOVIES
-- Ex 1
select ADDRESS from STUDIO where NAME = "MGM";
-- Ex 2
select BIRTHDATE from MOVIESTAR where NAME = "Sandra Bullock";
-- Ex 3
select STARNAME from STARSIN where MOVIEYEAR = 1980 and MOVIETITLE LIKE "%Empire%";
-- Ex 4
select NAME from MOVIEEXEC where NETWORTH > 10000000;
-- Ex 5
select * from MOVIESTAR where GENDER = 'M' or ADDRESS = "Malibu";

-- PC
-- Ex 1
select model, speed as "MHz", hd as "GB" from pc where price < 1200;
-- Ex 2
select model, (price / 1.1) as "euro price" from pc order by price asc;
-- Ex 3
select model, ram, screen from laptop where price > 1000;
-- Ex 4
select * from printer where color = "y";
-- Ex 5
select model, speed, hd from pc where (cd = "12x" or cd = "16x") and price < 2000;
-- Ex 6
select code, model, (speed + ram + 10 * screen) as rating from laptop;
-- Ex 7
select code, model, (speed + ram + 10 * screen) as rating from laptop order by rating desc, code asc;

-- SHIPS
-- Ex 1
select CLASS, COUNTRY from CLASSES where NUMGUNS < 10;
-- Ex 2
select NAME as shipName from SHIPS where LAUNCHED < 1918;
-- Ex 3
select SHIP, BATTLE from OUTCOMES where RESULT = "sunk";
-- Ex 4
select NAME from SHIPS where NAME = CLASS;
-- Ex 5
select NAME from SHIPS where NAME like "R%";
-- Ex 6
select NAME from SHIPS where NAME like "% %" and NAME not like "% % %";