50. Kid-Friendly Movies in Last Month

Media streaming companies want to analyze how much kid-friendly movie content was broadcast during a specific month to optimize children's programming. This helps in planning future programming schedules and tracking engagement among the young audience.

You are given two tables:

TVProgram

╔═══════════════╦══════════╗
β•‘ Column Name   β•‘   Type   β•‘
╠═══════════════╬══════════╣
β•‘ program_date  β•‘   date   β•‘
║───────────────┼──────────║
β•‘  content_id   β•‘   int    β•‘
║───────────────┼──────────║
β•‘    channel    β•‘ varchar  β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•
  • program_date: The date the content was aired
  • content_id: The ID of the content aired (links to Content.content_id)
  • channel: The channel where the content was broadcasted
  • Primary Key: (program_date, content_id) this ensures each content can appear once per day per channel, uniquely identified.

Content

╔═══════════════╦══════════════════╗
β•‘ Column Name   β•‘      Type        β•‘
╠═══════════════╬══════════════════╣
β•‘  content_id   β•‘     varchar      β•‘
║───────────────┼──────────────────║
β•‘     title     β•‘     varchar      β•‘
║───────────────┼──────────────────║
β•‘ Kids_content  β•‘ enum('Y','N')    β•‘
║───────────────┼──────────────────║
β•‘ content_type  β•‘     varchar      β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
  • content_id: Unique identifier for the content (Primary Key)
  • title: Title of the content
  • Kids_content: 'Y' if it is suitable for kids, 'N' otherwise
  • content_type: Type of content: e.g., 'movie', 'series', 'documentary', etc.

Write a query to return the distinct titles of kid-friendly movies that were streamed in June 2020. The result can be in any order.

Example 1:

Example:

Input:

TVProgram Table

╔═══════════════════╦═══════════╦═══════════╗
β•‘   program_date    β•‘content_id β•‘  channel  β•‘
╠═══════════════════╬═══════════╬═══════════╣
β•‘ 2020-06-10 08:00  β•‘     1     β•‘VC-Channel β•‘
║───────────────────┼───────────┼───────────║
β•‘ 2020-05-11 12:00  β•‘     2     β•‘VC-Channel β•‘
║───────────────────┼───────────┼───────────║
β•‘ 2020-06-12 12:00  β•‘     3     β•‘VC-Channel β•‘
║───────────────────┼───────────┼───────────║
β•‘ 2020-05-13 14:00  β•‘     4     β•‘ Disney Ch β•‘
║───────────────────┼───────────┼───────────║
β•‘ 2020-06-18 14:00  β•‘     4     β•‘ Disney Ch β•‘
║───────────────────┼───────────┼───────────║
β•‘ 2020-07-15 16:00  β•‘     5     β•‘ Disney Ch β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•

Content Table

╔═══════════╦════════════════╦══════════════╦══════════════╗
β•‘content_id β•‘     title      β•‘Kids_content  β•‘content_type  β•‘
╠═══════════╬════════════════╬══════════════╬══════════════╣
β•‘     1     β•‘ Cheatcode Movieβ•‘      N       β•‘    Movies    β•‘
║───────────┼────────────────┼──────────────┼──────────────║
β•‘     2     β•‘ Alg. for Kids  β•‘      Y       β•‘    Series    β•‘
║───────────┼────────────────┼──────────────┼──────────────║
β•‘     3     β•‘ Database Sols  β•‘      N       β•‘    Series    β•‘
║───────────┼────────────────┼──────────────┼──────────────║
β•‘     4     β•‘    Aladdin     β•‘      Y       β•‘    Movies    β•‘
║───────────┼────────────────┼──────────────┼──────────────║
β•‘     5     β•‘   Cinderella   β•‘      Y       β•‘    Movies    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Expected Output:

╔═════════╗
β•‘  title  β•‘
╠═════════╣
β•‘ Aladdin β•‘
β•šβ•β•β•β•β•β•β•β•β•β•

Explanation:

  • Aladdin: Kid-friendly (Y), movie, and streamed on 2020-06-18 (included)
  • Cinderella: Kid-friendly, movie, but streamed in July, not June (excluded)
  • Alg. for Kids: Kid-friendly, but is a series, not movie (excluded)
  • Cheatcode Movie: A movie, but not for kids (excluded)

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Hints

0
Β 
Test Case

Input:

Content
TVProgram