-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodecademy-SQL-challenge-Davies-Burgers.sqlite
More file actions
77 lines (65 loc) · 2.03 KB
/
codecademy-SQL-challenge-Davies-Burgers.sqlite
File metadata and controls
77 lines (65 loc) · 2.03 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
.width 3
-- 1
-- What are the column names?
SELECT *
FROM orders
LIMIT 10;
-- 2
-- How recent is this data?
SELECT DISTINCT order_date
FROM orders;
-- 3
-- Instead of selecting all the columns using *,
-- write a query that selects only the special_instructions column.
-- Limit the result to 20 rows.
SELECT special_instructions
FROM orders
LIMIT 20;
-- 4
-- Can you edit the query so that we are only
-- returning the special instructions that are not empty?
SELECT special_instructions
FROM orders
WHERE special_instructions IS NOT NULL;
-- 5
-- Let’s go even further and sort the instructions
-- in alphabetical order (A-Z).
SELECT special_instructions
FROM orders
WHERE special_instructions IS NOT NULL
ORDER BY special_instructions;
-- 6
-- Let’s search for special instructions that have the word ‘sauce’.
SELECT special_instructions
FROM orders
WHERE special_instructions LIKE '%sauce%';
-- Are there any funny or interesting ones?
-- Nope!
-- 7
-- Let’s search for special instructions that have the word ‘door’.
-- Any funny or interesting ones? Haha, yes.
SELECT special_instructions
FROM orders
WHERE special_instructions LIKE '%door%';
-- 8
-- Let’s search for special instructions that have the word ‘box’.
-- Any funny or interesting ones? "Draw a dragon fighting flamingo on the pizza box."
SELECT special_instructions
FROM orders
WHERE special_instructions LIKE '%box%';
-- 9
-- Instead of just returning the special instructions, also return their order ids.
-- For more readability:
-- Rename id as ‘#’
-- Rename special_instructions as ‘Notes’
SELECT id AS '#', special_instructions AS 'Notes'
FROM orders
WHERE special_instructions IS NOT NULL;
-- 10
-- Challenge
-- They have asked you to query the customer who made the phrase.
-- Return the item_name restaurant_id, and user_id for the person created the phrase.
-- .mode column
SELECT item_name, restaurant_id, user_id
FROM orders
WHERE special_instructions LIKE '%dragon%';