The Publishing Audit

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Netflix

Problem

The content analytics team is auditing the 2026 publishing pipeline. Pull all fields for content items published during that year.

Published years ago. Still generating views?

Tables

content_items

Columns: content_id INTEGER, title TEXT, content_type TEXT, duration_seconds INTEGER, creator_id INTEGER, publish_date TEXT

content_items: 10 of 200 rows
content_idtitlecontent_typeduration_secondscreator_idpublish_date
243The Ultimate Guide to AI TrendsarticleNULL1972026-02-02
286Top 10 Mobile Appspodcast1542942025-03-03
329Understanding Machine Learning [DRAFT]short2013912026-04-04
372Mastering Tech Startupslivestream2484882025-05-05
415Introduction to Cybersecurityvideo2955852026-06-06
458Deep Dive: Cloud ComputingarticleNULL6822025-07-07
501Behind the Scenes of Product Managementpodcast3897792026-08-08
544Breaking Down DevOpsshort4368762025-09-09
587Exploring Web Developmentlivestream483NULL2026-01-10
630How to Data Sciencevideo53010702025-11-11

Expected output

First 5 of 61 rows
content_idtitlecontent_typeduration_secondscreator_idpublish_date
243The Ultimate Guide to AI TrendsarticleNULL1972026-02-02
329Understanding Machine Learning [DRAFT]short2013912026-04-04
415Introduction to Cybersecurityvideo2955852026-06-06
501Behind the Scenes of Product Managementpodcast3897792026-08-08
587Exploring Web Developmentlivestream483NULL2026-01-10

Worked solution and explanation

What this is really asking

This is a calendar-year boundary problem wearing an audit costume. Everyone writes a filter on publish_date. What separates candidates is whether that predicate covers the whole year, '2026-01-01' through '2026-12-31' with both ends included, on the bare column, and whether they leave every other field alone. Read 'during that year' as one date and you get a single day's publishes. Add a tidy-looking guard on duration_seconds and the 10 items with no duration drop out of an audit that needed all 61.


Break down the requirements

Step 1: Return every field

SELECT * is the right call here, not a lazy one. The audit wants the raw row shape. Rows with an empty duration_seconds or creator_id are still 2026 publishes, so nothing but the date decides inclusion.

Step 2: Bound the year on the bare column

Use January 1 through December 31, both ends included. publish_date holds ISO 'YYYY-MM-DD' text, so the range compares correctly, and the 12 undated items fall out on their own because a NULL never satisfies a range.


The solution

PUBLISHING AUDIT FOR ONE YEAR
SELECT *
FROM content_items
WHERE publish_date BETWEEN '2026-01-01' AND '2026-12-31'

COMMON FOLLOW-UP QUESTIONS

Common follow-up questions