You are given two tables: TVProgram and Content.
The TVProgram table contains information about TV programs:
program_date: The date when the program was airedcontent_id: The ID of the contentchannel: The TV channel name
The Content table contains details about each content:
content_id: Unique identifier for the contenttitle: The title of the contentKids_content: Whether it's kid-friendly ('Y') or not ('N')content_type: Type of content (movies, series, etc.)
Write a SQL query to find the distinct titles of kid-friendly movies that were streamed in June 2020.
Table Schema
| Column Name | Type | Description |
|---|---|---|
program_date
PK
|
date | Date when the program was aired |
content_id
PK
|
int | ID of the content (foreign key to Content table) |
channel
|
varchar | TV channel name |
| Column Name | Type | Description |
|---|---|---|
content_id
PK
|
varchar | Unique identifier for the content |
title
|
varchar | Title of the content |
Kids_content
|
enum | Whether content is for kids: 'Y' (yes) or 'N' (no) |
content_type
|
varchar | Type of content (movies, series, etc.) |
Input & Output
| program_date | content_id | channel |
|---|---|---|
| 2020-06-10 | 1 | Disney Channel |
| 2020-06-15 | 2 | Nickelodeon |
| 2020-07-01 | 3 | HBO |
| content_id | title | Kids_content | content_type |
|---|---|---|---|
| 1 | Moana | Y | Movies |
| 2 | Frozen | Y | Movies |
| 3 | The Dark Knight | N | Movies |
| title |
|---|
| Moana |
| Frozen |
From the TVProgram table, we find programs aired in June 2020 (2020-06-10 and 2020-06-15). Joining with Content table, both Moana and Frozen are kid-friendly movies (Kids_content = 'Y' and content_type = 'Movies'). The program on 2020-07-01 is excluded as it's in July.
| program_date | content_id | channel |
|---|---|---|
| 2020-06-05 | 4 | Cartoon Network |
| 2020-06-20 | 5 | Disney XD |
| content_id | title | Kids_content | content_type |
|---|---|---|---|
| 4 | Tom and Jerry | Y | Series |
| 5 | Toy Story | Y | Movies |
| title |
|---|
| Toy Story |
Both programs aired in June 2020 and are kid-friendly, but only 'Toy Story' is a movie. 'Tom and Jerry' is excluded because it's a series, not a movie.
| program_date | content_id | channel |
|---|---|---|
| 2020-06-12 | 6 | Adult Swim |
| content_id | title | Kids_content | content_type |
|---|---|---|---|
| 6 | Deadpool | N | Movies |
| title |
|---|
Although 'Deadpool' is a movie that aired in June 2020, it's not kid-friendly (Kids_content = 'N'), so no results are returned.
Constraints
-
program_dateis in formatYYYY-MM-DD -
Kids_contentis either'Y'or'N' -
content_typeincludes'Movies','Series', etc. -
Multiple programs can have the same
content_idon different dates