New Kids-Safe Originals for the Family Row

Easy
473.

New Kids-Safe Originals for the Family Row

EasyBasics

MySQL

The home screen of an OTT video app has a "Family Originals" row. A title belongs in it when it is one of the service's own originals, its certificate is U or U/A 7+, and it was released in 2023 or later.

Return the columns title_id and title_name of every title that qualifies. Titles produced by other studios (is_original = 0) never qualify, whatever their certificate. Return the rows in any order.

Tables

Table: Title

ColumnTypeValues
title_idint
title_namevarchar
kindenummovie, series
maturity_ratingenumU, U/A 7+, U/A 13+, U/A 16+, A
release_yearint
is_originalbool

Primary key: title_id.

One row per title in the catalogue. is_original is 1 for the service's own productions, 0 for licensed titles.

Example

The rows may come back in any order; the columns must be the ones shown, in that order.

Title

title_idtitle_namekindmaturity_ratingrelease_yearis_original
1Little AstronautsseriesU20241
2Midnight MumbaiseriesA20241
3Paper BoatsmovieU/A 7+20231
4Ocean KidsseriesU20221
5Space MonkeysmovieU20250
6RangolimovieU/A 13+20231
7Kites Over JaipurmovieU/A 7+20251

Output

title_idtitle_name
1Little Astronauts
3Paper Boats
7Kites Over Jaipur
Read the hints, the editorial and the reference solution
-- Write your MySQL query below

Sign in to write, run and submit queries

A free account — no card, no trial clock. You come straight back here.

Run your query to see its result next to the expected one, example by example.

New Kids-Safe Originals for the Family Row — SQL Problem

The home screen of an OTT video app has a "Family Originals" row.

  • Difficulty: Easy
  • Topics: Basics
  • Dialect: MySQL
  • Problem: #473

Problem statement

The home screen of an OTT video app has a "Family Originals" row. A title belongs in it when it is one of the service's own originals, its certificate is U or U/A 7+, and it was released in 2023 or later.

Return the columns title_id and title_name of every title that qualifies. Titles produced by other studios (is_original = 0) never qualify, whatever their certificate. Return the rows in any order.

Tables

Table: Title

ColumnType
title_idint
title_namevarchar
kindenum(movie, series)
maturity_ratingenum(U, U/A 7+, U/A 13+, U/A 16+, A)
release_yearint
is_originalbool

Primary key: title_id.

One row per title in the catalogue. is_original is 1 for the service's own productions, 0 for licensed titles.

Examples

Example 1

Title

title_idtitle_namekindmaturity_ratingrelease_yearis_original
1Little AstronautsseriesU20241
2Midnight MumbaiseriesA20241
3Paper BoatsmovieU/A 7+20231
4Ocean KidsseriesU20221
5Space MonkeysmovieU20250
6RangolimovieU/A 13+20231
7Kites Over JaipurmovieU/A 7+20251

Output

title_idtitle_name
1Little Astronauts
3Paper Boats
7Kites Over Jaipur

How to solve New Kids-Safe Originals for the Family Row

This is a pure filter over one table: no join, no grouping. Each row is checked against three conditions and kept only if every one holds, so they are combined with AND.

The certificate test allows two values. maturity_rating IN ('U', 'U/A 7+') is shorthand for two equalities joined by OR; if you write the OR form yourself, wrap it in parentheses, because AND binds tighter than OR and a AND b OR c would let any U/A 7+ title in regardless of the other conditions. The year test is inclusive — a title from 2023 belongs in the row — so it is >= 2023 (or > 2022).

is_original is a 0/1 flag, so is_original = 1 keeps the service's own productions. The query reads every row once; on a large catalogue an index on (is_original, release_year) would let the engine skip most of it.

Reference solution (MySQL)

SELECT title_id, title_name
FROM Title
WHERE is_original = 1
  AND maturity_rating IN ('U', 'U/A 7+')
  AND release_year >= 2023

Another way

SELECT title_id, title_name FROM Title WHERE is_original = 1 AND (maturity_rating = 'U' OR maturity_rating = 'U/A 7+') AND release_year > 2022

Another way

SELECT title_id, title_name FROM Title WHERE is_original <> 0 AND release_year BETWEEN 2023 AND 9999 AND maturity_rating NOT IN ('U/A 13+', 'U/A 16+', 'A')

← Orange Cap Leader After Every Match Day · Profiles With No Streams Since the New Year →