Content Published in 2026

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

Problem

content_items holds one row per piece of content, each stamped with the day it was published, going back several years. Return the full record of every piece published at any point in 2026.

Published back then. Still relevant?

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 really is

Strip away the content framing and this is a whole-year window over dates stored as text. publish_date holds 'YYYY-MM-DD' strings spanning five years, so with no filter you get all 200 pieces, and comparing the column to the bare year gets you none of them. Anyone can write a WHERE clause. What separates candidates is the boundary: close the window a day early and the year's last pieces disappear from the audit, with no error to warn you.

Step 1: Name the columns the record needs

The ask is the full record, so list all six columns of content_items instead of writing SELECT *. The output is the same today, and the shape stays fixed when someone adds a column next quarter.

Step 2: Bound the year at both ends

publish_date BETWEEN '2026-01-01' AND '2026-12-31' is inclusive on both sides. A piece published on the first day or the last day of the year still belongs to that year, and this check keeps both.

Step 3: Let undated pieces fall out

Twelve rows have a NULL publish_date. BETWEEN evaluates to unknown for them, and WHERE keeps only rows that are true. That is the correct outcome, because a piece with no date was not published in any year.

Single-year filter
SELECT
    content_id,
    title,
    content_type,
    duration_seconds,
    creator_id,
    publish_date
FROM content_items
WHERE publish_date BETWEEN '2026-01-01' AND '2026-12-31'

One inclusive range on publish_date, every column named.

Inclusive BETWEEN (day-level dates)
publish_date BETWEEN '2026-01-01' AND '2026-12-31'. This is clean and correct while the column holds plain days.
Half-open window (timestamp-safe)
publish_date >= '2026-01-01' AND publish_date < '2027-01-01'. This catches every instant of the last day, and you never have to reason about the year's final second.

Common follow-up questions