Repository navigation
Expand file tree
/
Copy path23-28.sql
More file actions
70 lines (62 loc) · 2.06 KB
/
Copy path23-28.sql
File metadata and controls
70 lines (62 loc) · 2.06 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Product(maker, model, type)
PC(code, model, speed, ram, hd, cd, price)
Laptop(code, model, speed, ram, hd, price, screen)
Printer(code, model, color, type, price)
--23--
select distinct Product.maker
from Product
inner join pc on Product.model=pc.model
Where pc.speed >= 750 and exists(
select pd.maker
from Product Pd
inner join Laptop lt on pd.model=lt.model
Where Product.maker=pd.maker and lt.speed >= 750)
--24--
select distinct model from (
select model, price
from pc
Where price = (select max(price) from pc pcc)
Union
select model, price
from Laptop
Where price = (select max(price) from Laptop lpt)
Union
select model, price
from Printer
Where price = (select max(price) from Printer prt))
Where price = (select max(price) from (
select model, price
from pc
Where price = (select max(price) from pc pcc)
Union
select model, price
from Laptop
Where price = (select max(price) from Laptop lpt)
Union
select model, price
from Printer
Where price = (select max(price) from Printer prt)))
--25--
select distinct Product.maker
from Product, pc
Where Product.model=pc.model and product.type = 'PC'
and pc.ram = (select min(pcc.ram) from pc pcc where pcc.ram <> 0) and pc.speed = (select max(pccc.speed) from pc pccc
where pccc.ram = (select min(pcc.ram) from pc pcc where pcc.ram <> 0))
and exists(select p.maker from Product p
where p.type = 'Printer' and p.maker=product.maker)
--26--
select avg(price) from (
select pc.price as price, pc.model as model, product.type
from pc, product Where pc.model = product.model and product.maker = 'A' and product.type='PC'
Union all
select lpt.price as price, lpt.model as model, product.type
from Laptop lpt, product Where lpt.model = product.model and product.maker = 'A' and product.type='Laptop')
--27--
select product.maker, avg(pc.hd)
from product, pc
Where product.model=pc.model and product.type='PC' and exists(select pr.model from product pr where pr.maker = product.maker and pr.type='Printer')
Group by maker
--28--
select count(maker) qty
from product
Where (select count(model) from product pr where product.maker=pr.maker) = 1