Carvana's Product Analytics team wants to understand how shoppers move through vehicle detail pages during completed web sessions. Write a PostgreSQL query using LAG and LEAD to expose the previous and next action surrounding each vehicle view.
vehicle_view event, including the previous event type, next event type, and seconds until the next event.event_id as a tie-breaker.NULL when there is no previous or next event.| Column | Type | Description |
|---|---|---|
| session_idPK | VARCHAR(20) | Unique browsing session identifier |
| user_id | INT | Shopper identifier |
| platform | VARCHAR(20) | Product platform used during the session |
| session_status | VARCHAR(20) | Outcome of the browsing session |
| started_at | TIMESTAMP | Session start timestamp |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier |
| session_id | VARCHAR(20) | Session associated with the event |
| vehicle_id | VARCHAR(20) | Carvana vehicle associated with the event |
| event_type | VARCHAR(30) | Action recorded on the product surface |
| event_ts | TIMESTAMP | Event occurrence timestamp |