-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZipkin Lab 4.sql
76 lines (62 loc) · 1.27 KB
/
Zipkin Lab 4.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--Joshua D. Zipkin
--Query 1
select city
from agents
where aid in (select aid
from orders
where cid in (select cid
from customers
where name = 'Basics'))
order by city asc;
--Query 2
select pid
from orders
where aid in (select aid
from orders
where cid in (select cid
from customers
where city = 'Kyoto'))
order by pid asc;
--Query 3
select cid, name
from customers
where cid not in (select cid
from orders
where aid = 'a03');
--Query 4
select cid, name
from customers
where cid in (select cid
from orders
where pid = 'p01'
and cid in (select cid
from orders
where pid = 'p07'));
--Query 5
select pid
from orders
where cid in (select cid
from orders
where aid = 'a03')
order by pid asc;
--Query 6
select name, discount
from customers
where cid in (select cid
from orders
where aid in (select aid
from agents
where city = 'Dallas'
or city = 'Duluth'))
order by name asc;
--Query 7
select *
from customers
where cid in (select cid
from customers
where discount in (select discount
from customers
where city = 'Dallas'
or city = 'Kyoto'))
and city != 'Dallas'
and city != 'Kyoto';