Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Most Common User Navigation Paths
00:00
5 left

Most Common User Navigation Paths

MediumSQL · PostgreSQL

Problem

NovaFlow wants to understand how users move through its product. Write a PostgreSQL query to identify the most common 3-step navigation paths users take within a session.

Use the event stream to build ordered page paths from consecutive events. Only include sessions tied to active users, and ignore events where page_name is NULL.

Requirements

  1. Build 3-step paths using each user's ordered events within the same session.
  2. Use event timestamp order, and break ties with event_id.
  3. Only include sessions from users where users.is_active = TRUE.
  4. Exclude incomplete paths where step 2 or step 3 is missing.
  5. Return each unique path, the number of distinct sessions that followed it, and its rank by popularity.
  6. Sort by path rank, then path name.

Schema

users
ColumnTypeDescription
user_idPKINTPrimary key for the user
user_nameVARCHAR(100)User's full name
signup_dateDATEDate the user signed up
is_activeBOOLEANWhether the user is currently active
sessions
ColumnTypeDescription
session_idPKINTPrimary key for the session
user_idINTUser who owns the session
session_startTIMESTAMPTimestamp when the session started
device_typeVARCHAR(50)Device type used in the session
events
ColumnTypeDescription
event_idPKINTPrimary key for the event
session_idINTSession where the event occurred
event_timeTIMESTAMPTimestamp of the event
page_nameVARCHAR(100)Page or screen viewed by the user
event_typeVARCHAR(50)Type of event recorded
Tablesuserssessionsevents
Interviewer

Your question is Most Common User Navigation Paths. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.