Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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
Daily Session Funnel Conversion Rates
00:00
5 left

Daily Session Funnel Conversion Rates

HardSQL · PostgreSQL

Problem

Context

A retail analytics team wants to analyze user conversion through the product funnel on a daily basis. Each event in the clickstream_events table is associated with a session. Funnel steps are: product_view, add_to_cart, checkout_start, purchase.

Task

Write a SQL query to compute, for each session start date:

  1. The number of sessions started
  2. The number of sessions with at least one product_view
  3. The number of sessions with at least one add_to_cart
  4. The number of sessions with at least one checkout_start
  5. The number of sessions with at least one purchase
  6. The conversion rate from product_view to add_to_cart (as a decimal, rounded to 1 decimal place)
  7. The conversion rate from product_view to purchase (as a decimal, rounded to 1 decimal place)

Requirements

  • Each session is counted only once per funnel step, regardless of how many times the event occurs in the session.
  • Conversion rates are calculated as: sessions_with_add_to_cart / sessions_with_product_view and sessions_with_purchase / sessions_with_product_view. If the denominator is zero, return 0.0.
  • Output one row per session start date, ordered by date ascending.

Schema

clickstream_events
ColumnTypeDescription
event_idPKBIGINTPrimary key
user_idBIGINTUser identifier (not unique per session)
session_idVARCHAR(64)Session identifier; used to group events into sessions
event_tsTIMESTAMPEvent timestamp in UTC
event_nameVARCHAR(50)Event type (e.g., product_view, add_to_cart)
page_urlVARCHAR(500)URL where the event occurred; nullable depending on instrumentation
Tablesclickstream_events
Interviewer

Your question is Daily Session Funnel Conversion Rates. Start with the requirements and the one table 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.