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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Weekly Active SMBs by Month
00:00
5 left

Weekly Active SMBs by Month

MediumSQL · PostgreSQL

Problem

Intuit wants a simple monthly view of SMB engagement across product events. Write a SQL query to calculate the average number of active SMBs per active week in each month.

Requirements

  1. Use only rows where account_type = 'SMB'.
  2. Ignore rows where event_name is NULL.
  3. Count distinct smb_id values as active SMBs.
  4. For each month, divide the distinct active SMB count by the number of distinct week buckets in that month.
  5. Return the month formatted as YYYY-MM and the average rounded to 2 decimal places.
  6. Order the result by month ascending.

Schema

smb_product_events
ColumnTypeDescription
event_idPKINTUnique event row identifier
smb_idINTSMB account identifier
account_typeVARCHAR(20)Customer segment
product_nameVARCHAR(50)Product where the event occurred
event_nameVARCHAR(50)Tracked user action
event_dateDATEDate the event occurred
Tablessmb_product_events
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the one table are in the Question tab.

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.