-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday-02.sql
More file actions
26 lines (23 loc) · 947 Bytes
/
day-02.sql
File metadata and controls
26 lines (23 loc) · 947 Bytes
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
-- SQL Advent Calendar - Day 2
-- Title: Toys Delivered - Find Which Toys Made It
-- Difficulty: medium
--
-- Question:
-- Santa wants to analyze which toys that were produced in his workshop have already been delivered to children. You are given two tables on toy production and toy delivery — can you return the toy_id of the toys that have been delivered?
--
-- Santa wants to analyze which toys that were produced in his workshop have already been delivered to children. You are given two tables on toy production and toy delivery — can you return the toy ID and toy name of the toys that have been delivered?
--
-- Table Schema:
-- Table: toy_production
-- toy_id: INTEGER
-- toy_name: VARCHAR
-- production_date: DATE
--
-- Table: toy_delivery
-- toy_id: INTEGER
-- child_name: VARCHAR
-- delivery_date: DATE
--
-- My Solution:
select toy_id, toy_name from toy_production
where toy_id in (select toy_id from toy_delivery)