AnalystPath

Accounts Streaming From Two Devices at Once

SQLMediumMid level~15 min

Problem

Table: `stream_session`

| Column Name | Type |
|---|---|
| profile_id | int |
| device_id | int |
| started_at | datetime |
| ended_at | datetime |

There is no primary key. Each row is one viewing session: a profile streamed from a device between `started_at` and `ended_at`.

A profile is flagged for sharing when it had **two sessions on different devices that overlapped in time** (one session started while another, on a different device, was still running). Return the distinct `profile_id` of every such profile.

Tables

Example rows — the live problem includes the full dataset.

stream_session
profile_iddevice_idstarted_atended_at
11002026-01-01 10:00:002026-01-01 11:00:00
12002026-01-01 10:30:002026-01-01 12:00:00
23002026-01-01 08:00:002026-01-01 09:00:00

Expected output

Your answer should return 1 row with the columns profile_id.

Starter code (SQL)

SELECT *
FROM stream_session;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions