Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Conversion by Channel and Device

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

Your question is SQL Conversion by Channel and Device. 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

PayPal Product Growth wants to compare how effectively acquisition channels convert users into completed PayPal Checkout sessions across device types. Write a PostgreSQL query for sessions acquired during January 2025.

Requirements

  1. Group results by acquisition channel and device type, replacing NULL values with Unknown.
  2. Count total acquisition sessions and sessions with at least one completed PayPal Checkout event during January 2025.
  3. Calculate conversion rate as converted sessions divided by total sessions, expressed as a percentage rounded to two decimals.
  4. Include groups with zero conversions and order results by channel, then device type.

Schema

acquisition_sessions
ColumnTypeDescription
session_idPKINTUnique acquisition session identifier
user_idINTPayPal user identifier
channelVARCHAR(40)Acquisition channel
device_typeVARCHAR(20)Device used to start the session
started_atTIMESTAMPSession start timestamp
payment_events
ColumnTypeDescription
event_idPKINTUnique payment event identifier
session_idINTAcquisition session associated with the event
event_typeVARCHAR(30)Payment funnel event type
event_atTIMESTAMPPayment event timestamp
Tablesacquisition_sessionspayment_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results