-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.txt
More file actions
64 lines (44 loc) · 1.27 KB
/
sql.txt
File metadata and controls
64 lines (44 loc) · 1.27 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
1.
select name from member,book,checkout_item where checkout_item.member_id=member.id and checkout_item.book_id=book.id and book.title='The Hobbit’;
Output :: Anand Beck
2.
select distinct count(*)
from member
where id not in(select distinct member_id
from checkout_item);
Output:37
3.
select distinct title
from book
where id not in(select distinct book_id
from checkout_item
where book_id is not null)
union
select distinct title
from movie
where id not in(select distinct movie_id
from checkout_item
where movie_id is not null);
Output:1984
Catcher in the Rye
Crouching Tiger, Hidden Dragon
Domain Driven Design
Fellowship of the Ring
Lawrence of Arabia
Office Space
Thin Red Line
To Kill a Mockingbird
Tom Sawyer
4.
insert into book(id,title) values(11,'The Pragmatic Programmer');
insert into member(id,name) values(43,'Sai Sree');
insert into checkout_item(member_id,book_id,movie_id) values(43,11,null);
select name from member,book,checkout_item where checkout_item.member_id=member.id and checkout_item.book_id=book.id and book.title='The Pragmatic Programmer';
Output: Sai Sree
5.
select name
from member,checkout_item
where checkout_item.member_id=member.id
GROUP BY (checkout_item.member_id) having count(checkout_item.member_id)>1;
output:Anand Beck
Frank Smith