Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Analyze Ecommerce Conversion Funnel

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

Your question is Analyze Ecommerce Conversion Funnel. 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

NovaCart wants to measure how users move through a simple purchase funnel: visit → checkout → purchase. Write a SQL query to calculate funnel performance by visit date.

Your query should use the event stream and user data to report how many distinct users reached each stage on each day, along with conversion rates between stages.

Requirements

  1. For each visit_date, count distinct users who had a visit, then a checkout, then a purchase on the same day.
  2. A user should count at a later stage only if they also reached the earlier stage that day.
  3. Return visit_date, visitors, checkout_users, purchase_users, visit_to_checkout_rate, and checkout_to_purchase_rate.
  4. Include only users from the web acquisition channel.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
signup_dateDATEDate the user signed up
acquisition_channelVARCHAR(20)Channel that acquired the user
countryVARCHAR(20)User country
events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser who generated the event
event_nameVARCHAR(20)Event type in the funnel
event_timeTIMESTAMPTimestamp of the event
session_idVARCHAR(20)Session identifier
Tablesusersevents
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results