Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clean Motive Event Funnel Data

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

Your question is Clean Motive Event Funnel Data. Start with the requirements and the three 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

You are given raw event logs from Motive products and asked to reshape them into a user-day product activity table for analysis. Write a PostgreSQL query that returns one row per user per event date for valid product events only, with the users company name, a cleaned product surface, counts of total valid events and distinct sessions, and a flag showing whether the user triggered a conversion event that day.

Treat view, click, and submit as valid events. Exclude internal users, events with missing user_id, and events whose event_name is null. Map driver_app_home and driver_app_settings to Driver App, fleet_dashboard_overview and fleet_dashboard_reports to Fleet Dashboard, and all other non-null surfaces to Other. A conversion is any valid submit event.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
company_idINTCompany associated with the user
user_nameVARCHAR(100)User display name
is_internalBOOLEANWhether the account is internal
companies
ColumnTypeDescription
company_idPKINTUnique company identifier
company_nameVARCHAR(100)Company name
product_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser who triggered the event
event_timeTIMESTAMPTimestamp of the event
session_idVARCHAR(50)Session identifier
event_nameVARCHAR(50)Raw event type
product_surfaceVARCHAR(100)Raw product surface name
Tablesuserscompaniesproduct_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results