forked from Cathe313/mysql-workshop-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise_3.txt
62 lines (39 loc) · 1018 Bytes
/
exercise_3.txt
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
[ Exercise 3 ]
SELECT LOWER(country), COUNT(country) AS occurence
FROM Address
GROUP BY country
ORDER BY COUNT(country) DESC;
[ Exercise 4 ]
SELECT *
FROM Entry
JOIN AddressBook
ON Entry.addressBookId = AddressBook.id
WHERE AddressBook.name="Pharetra Ut Limited";
[ Exercise 5 ]
SELECT email
FROM Account
JOIN AddressBook
ON Account.id = AddressBook.accountId
WHERE AddressBook.id = 100;
[ Exercise 6 ]
SELECT content
FROM Phone
JOIN Entry
ON Phone.entryId = Entry.id
WHERE Entry.firstName = "Charlotte" AND Entry.lastName = 'Jenkins'
[ Exercise 7 ]
SELECT SUBSTRING_INDEX ( content, '@' ,-1)
FROM ElectronicMail;
[ Exercise 8 ]
SELECT COUNT(*)
FROM Phone
JOIN Entry
ON Phone.entryId = Entry.id
WHERE birthday BETWEEN '1950-10-01' AND '1960-10-31'
GROUP BY Phone.subtype;
[ Exercise 9 ]
SELECT city, country
FROM Address
WHERE country IN ('Canada', 'Austria', 'Isle of Man', 'Ireland', 'Japan')
[ Exercise 10 ]
Transform all work emails into home emails and vice versa. BE CAREFUL ;)