What was watched, without repeats

What was watched, without repeats

You work with the data of a streaming service. Plays are written into two tables: one for the browser web player, the other for the mobile app. The product team is building a "you have already watched this" block and asks for a directory of profile-to-title facts: which profile has ever started which title. How many times they rewatched it and on which device does not matter for this directory — every pair must appear exactly once. Return columns: - profile_id — viewer profile id (integer); - title_code — title code. Sorting: by profile_id ascending, then by title_code ascending. Each profile-title pair must land in the result exactly once, no matter how many times or on how many platforms it was played.

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.

profile_idtitle_code
101TT-DUNE
101TT-FARGO
101TT-OZARK
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid