ScienceDirect clickstream data can contain duplicate sessions caused by retries, browser behavior, or instrumentation issues. Write a PostgreSQL query to identify sessions that appear duplicated for the same user, device, and browser.
Treat a later session as a likely duplicate when it has the same user_id, device_type, and browser, and starts within five minutes of an earlier session. Use a self-join and conditional aggregation.
| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Elsevier platform user identifier |
| user_name | VARCHAR(100) | Display name for the user |
| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique clickstream session identifier |
| user_id | INT | User associated with the session |
| session_start | TIMESTAMP | Timestamp when the session began |
| device_type | VARCHAR(30) | Device category used for the session |
| browser | VARCHAR(40) | Browser reported by the client |
| landing_page | VARCHAR(200) | First page visited during the session |