-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek3_3.sql
More file actions
19 lines (19 loc) · 973 Bytes
/
Copy pathweek3_3.sql
File metadata and controls
19 lines (19 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--Find the names of sailors who have reserved boat no 103.
select s.sname from sailors s
where s.sid IN( select r.sid from reserves r
where r.bid=103);
--Find the names of sailors who have not reserved boat no 103.
select s.sname from sailors s
where s.sid NOT IN( select r.sid from reserves r
where r.bid=103);
--Find the sailor id with the highest rating
select s.sid from sailors s where s.rating>=all(select s1.rating from sailors s1);
--Find the sailor id whose rating is better than some sailor called andy
select s.sid from sailors s
where s.rating>ANY(select s1.rating from sailors s1 where s1.sname='Andy');
-- Find the names of sailors who have reserved boat no 103
select s.sname from sailors s where EXISTS(select * from reserves r where s.sid=r.sid and
r.bid=103);
Find the names of sailors who have not reserved boat no 103
select s.sname from sailors s where NOT EXISTS(select * from reserves r where s.sid=r.sid
and r.bid=103);