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
Clean Motive Event Funnel Data
00:00
5 left

Clean Motive Event Funnel Data

MediumSQL · PostgreSQL

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
Interviewer

Your question is Clean Motive Event Funnel Data. 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.