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 Quora Event Logs
00:00
5 left

Clean Quora Event Logs

MediumSQL · PostgreSQL

Problem

You are given messy event logs from Quora surfaces and asked to prepare a clean daily dataset for analysis. Write a PostgreSQL query that returns, for each event date and Quora surface, the number of valid events, the number of unique valid users, and the number of valid question views. Treat event names case-insensitively, trim extra whitespace from text fields, map question_view, Question View, and view_question to question_view, and map answer_click and Answer Click to answer_click. Exclude rows where the event timestamp is null, the user is inactive, the user does not exist, or the surface is blank/null after trimming.

Use the surface_map table to standardize surface names, keeping only rows that successfully map to a canonical Quora surface.

Schema

raw_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser who generated the event
event_nameVARCHAR(100)Raw event name captured in logs
event_tsTIMESTAMPTimestamp when the event occurred
surface_rawVARCHAR(100)Raw product surface name from the client
users
ColumnTypeDescription
user_idPKINTUnique user identifier
is_activeBOOLEANWhether the user is considered active
surface_map
ColumnTypeDescription
surface_rawPKVARCHAR(100)Observed raw surface label
canonical_surfaceVARCHAR(100)Canonical Quora surface name
Tablesraw_eventsuserssurface_map
Interviewer

Your question is Clean Quora Event Logs. 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.