Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

User Step-By-Step Navigation Query

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is User Step-By-Step Navigation Query. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Discover's data science team wants to analyze how users progress through the Discover Mobile App. Write a PostgreSQL query that lists each user's app interactions in chronological order and labels them as step1, step2, and so on.

Requirements

  1. Join users to their interaction records.
  2. Include only interactions from the Discover Mobile App surface.
  3. Exclude interactions where event_name is missing.
  4. Number each user's events chronologically, using interaction_id as a tie-breaker, and return the results in user and event order.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Discover customer identifier
full_nameVARCHAR(100)Customer display name
customer_segmentVARCHAR(30)Customer segmentation label
interactions
ColumnTypeDescription
interaction_idPKINTUnique interaction identifier
user_idINTCustomer associated with the interaction
product_surfaceVARCHAR(50)Discover product or channel where the event occurred
event_nameVARCHAR(60)Interaction event name
occurred_atTIMESTAMPTime when the interaction occurred
device_typeVARCHAR(20)Device used for the interaction
Tablesusersinteractions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results