-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog3userscript.sql
62 lines (55 loc) · 1.99 KB
/
prog3userscript.sql
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
# user execution script for Program #3 - CNT 4714 - Fall 2012
# all commands assumed to be executed by the root user
#
#Command 1:
# Query: Which rider won Milan-San Remo in 2010?
select ridername
from racewinners
where racename = 'Milan-San Remo' and raceyear = 2010;
#Command 2:
# Query: List the teams that ride bikes manufactured in Italy.
select teamname
from teams
where bikename in (select bikename
from bikes
where country_of_origin = 'Italy');
#Command 3:
# Query: List the name of every race won by a rider who has more than
# 50 professional wins.
select distinct racename
from racewinners
where ridername in (select ridername
from riders
where num_pro_wins > 50);
#Command 4:
# Query: List the names of all the riders on the same team as the winner of the
# 2010 Paris-Roubaix race.
select ridername
from riders
where teamname = (select teamname
from riders
where ridername = (select ridername
from racewinners
where racename = 'Paris-Roubaix'
and raceyear = 2010
)
);
#Command 5:
# Insert the rider Mark Renshaw into the riders table.
# * * Do a "before" and "after" selection on the riders table
select * from riders;
insert into riders values ('Mark Renshaw','HTC-Columbia','Australia',26);
select * from riders;
#Command 6:
# List the names of those riders who have won Paris-Roubaix at least two times.
select ridername
from racewinners
where racename = 'Paris-Roubaix'
group by ridername
having count(ridername) >= 2;
#Command 7:
# Delete all the riders from Norway from the riders table.
# * * * Do a "before" and "after" select * from riders for this command.
select * from riders;
delete from riders where nationality = 'Norway';
select * from riders;