-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday-20.sql
More file actions
35 lines (32 loc) · 1.08 KB
/
day-20.sql
File metadata and controls
35 lines (32 loc) · 1.08 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
-- SQL Advent Calendar - Day 20
-- Title: Hot Cocoa Break Logs
-- Difficulty: medium
--
-- Question:
-- Jack Frost wants to review all the cocoa breaks he actually took — including the cocoa type and the location he drank it in. How would you combine the necessary tables to show each logged break with its matching cocoa details and location?
--
-- Jack Frost wants to review all the cocoa breaks he actually took — including the cocoa type and the location he drank it in. How would you combine the necessary tables to show each logged break with its matching cocoa details and location?
--
-- Table Schema:
-- Table: cocoa_logs
-- log_id: INT
-- break_id: INT
-- cocoa_id: INT
--
-- Table: break_schedule
-- break_id: INT
-- location_id: INT
--
-- Table: cocoa_types
-- cocoa_id: INT
-- cocoa_name: VARCHAR
--
-- Table: locations
-- location_id: INT
-- location_name: VARCHAR
--
-- My Solution:
select * from cocoa_types as t
join cocoa_logs as l on t.cocoa_id = l.cocoa_id
join break_schedule as s on s.break_id = l.break_id
join locations as loc on loc.location_id = s.location_id