Documentary watchers

Documentary watchers

You work at the ReelFlow streaming service. The production team is launching a new documentary lineup and wants to send the announcement only to people who plausibly care: viewers who have already watched at least one title of the documentary genre. Watch events live in watch_history, profiles in viewers. Build the mailing list using an EXISTS check: a viewer makes the list if they have at least one watch record with genre 'documentary'. Each viewer must appear exactly once, no matter how many documentaries they watched. Return columns: - viewer_id — the viewer's id; - viewer_name — their name. Sort by viewer_id ascending.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

viewer_idviewer_name
1Alice Morgan
3Chloe Dubois
5Emma Stone
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid