Search ⌘K
F
Facebook

Interview Core Track · Hard · 35 min

9793 Average Time Between Steps

WITH step_differences AS ( SELECT feature_id, user_id, step_reached, timestamp, LEAD(timestamp) OVER (PARTITION BY feature_id, user_id ORDER BY step_reached)...

Interview Core Track
Hard
35 min
aggregation
date functions

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

Objective

Practice aggregation through a Facebook-tagged business scenario.

Approach

Use this track to improve speed, edge-case handling, and accuracy under timed conditions.

Company context

Company labels are directional practice context, not official interview guidance.

Prereq: query basics
Prereq: filtering

WITH step_differences AS ( SELECT feature_id, user_id, step_reached, timestamp, LEAD(timestamp) OVER (PARTITION BY feature_id, user_id ORDER BY step_reached) AS next_timestamp FROM facebook_product_features_realizations ), time_differences AS ( SELECT feature_id, EXTRACT(EPOCH FROM (next_timestamp - timestamp)) AS time_diff FROM step_differences WHERE next_timestamp IS NOT NULL ) SELECT feature_id, AVG(time_diff) AS avg_time_in_seconds FROM time_differences GROUP BY 1 ORDER BY 1

Pro question
This is a Pro question

Upgrade to Pro to unlock this prompt, the SQL workspace, and all 254 problems.

Upgrade to Pro — unlock all 254 problems
Editor
SQL workspace

Run queries against the protected question data, then submit once the result shape looks right.

Sign in to run SQL

Create a free account or sign in before running queries against protected question data.