Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Weekly Active SMBs by Month

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

Your question is Weekly Active SMBs by Month. Start with the requirements and the one table 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

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results