1495. Friendly Movies Streamed Last Month
Problem Statement
Find the distinct titles of kid-friendly movies streamed in June 2020. Return the result table in any order.
Table Schema
Table: TVProgram
+----------------+---------+
| program_date | date |
| content_id | int |
| channel | varchar |
+----------------+---------+
(program_date, content_id) is the primary key.
Table: Content
+------------------+---------+
| content_id | int |
| title | varchar |
| Kids_content | enum |
| content_type | varchar |
+------------------+---------+
content_id is the primary key. Kids_content: ENUM ('Y','N').
Examples
Example 1
Input Table:
TVProgram table:
+----------------+------------+---------+
| program_date | content_id | channel |
+----------------+------------+---------+
| 2020-06-10 | 1 | LC-Ch |
+----------------+------------+---------+
Content table:
+------------+-------+--------------+--------------+
| content_id | title | Kids_content | content_type |
+------------+-------+--------------+--------------+
| 1 | Toy Story | Y | Movies |
+------------+-------+--------------+--------------+
Expected Output:
+-----------+
| title |
+-----------+
| Toy Story |
+-----------+
SQL Solution
SELECT DISTINCT c.title
FROM TVProgram t
JOIN Content c ON t.content_id = c.content_id
WHERE c.Kids_content = 'Y'
AND c.content_type = 'Movies'
AND t.program_date BETWEEN '2020-06-01' AND '2020-06-30';
Problem Info
DifficultyEASY
Topics
joindistinctdate-filtering