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
SQL for Activity and User Metrics
00:00
5 left

SQL for Activity and User Metrics

HardSQL · PostgreSQL

Problem

ZoomInfo Technologies wants a daily view of activity volume in ZoomInfo Engage. Write a PostgreSQL query that reports activity and distinct-user counts by reportable activity type and calendar date.

Requirements

  1. Use the reporting range from 2025-01-01 through 2025-01-04, inclusive.
  2. Include every reportable activity type on every date, including combinations with no activities.
  3. Return the number of activities and distinct users who performed those activities. Activities without an associated user count toward activity volume but not the user count.
  4. Add the previous day's activity and user counts for the same activity type using a window function.
  5. Calculate day-over-day changes for both measures, preserving NULL for the first date because no prior date exists.
  6. Order results by activity type and activity date.

Schema

users
ColumnTypeDescription
user_idPKINTUnique ZoomInfo Engage user identifier
full_nameVARCHAR(100)User's display name
activity_types
ColumnTypeDescription
activity_type_idPKINTUnique activity type identifier
activity_typeVARCHAR(80)Name of the activity type
is_reportableBOOLEANIndicates whether the type appears in reporting
activities
ColumnTypeDescription
activity_idPKINTUnique activity identifier
activity_type_idINTReferenced activity type
user_idINTUser who performed the activity
activity_timestampTIMESTAMPTimestamp when the activity occurred
Tablesusersactivity_typesactivities
Interviewer

Your question is SQL for Activity and User Metrics. 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.