


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.
account_type = 'SMB'.event_name is NULL.smb_id values as active SMBs.YYYY-MM and the average rounded to 2 decimal places.smb_product_events
| Column | Type | Description |
|---|---|---|
| event_id | INT | Unique event row identifier |
| smb_id | INT | SMB account identifier |
| account_type | VARCHAR(20) | Customer segment |
| product_name | VARCHAR(50) | Product where the event occurred |
| event_name | VARCHAR(50) | Tracked user action |
| event_date | DATE | Date the event occurred |
| event_id | smb_id | account_type | product_name | event_name | event_date |
|---|---|---|---|---|---|
| 8 | 106 | SMB | Mailchimp | campaign_sent | 2024-02-03 |
| 2 | 101 | SMB | QuickBooks Online | invoice_created | 2024-01-03 |
| 11 | 108 | SMB | QuickBooks Online | login | 2024-02-15 |
| 1 | 101 | SMB | QuickBooks Online | login | 2024-01-02 |
| activity_month | avg_weekly_active_smbs |
|---|---|
| 2024-01 | 1.50 |
| 2024-02 | 1.00 |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event row identifier |
| smb_id | INT | SMB account identifier |
| account_type | VARCHAR(20) | Customer segment |
| product_name | VARCHAR(50) | Product where the event occurred |
| event_name | VARCHAR(50) | Tracked user action |
| event_date | DATE | Date the event occurred |
{"smb_product_events":[[8,106,"SMB","Mailchimp","campaign_sent","2024-02-03"],[2,101,"SMB","QuickBooks Online","invoice_created","2024-01-03"],[11,108,"SMB","QuickBooks Online","login","2024-02-15"],[1,101,"SMB","QuickBooks Online","login","2024-01-02"],[5,103,"SMB","QuickBooks Online","payment_received","2024-01-10"],[9,106,"SMB","Mailchimp",null,"2024-02-05"],[4,102,"SMB","QuickBooks Online","login","2024-01-09"],[10,107,"Mid-Market","QuickBooks Online","login","2024-02-06"],[3,101,"SMB","QuicOutput[["2024-01","1.50"],["2024-02","1.00"]]