Customer growth by month
1select
2 date_trunc(date(updated_at), month) as month
3 , count(*) as new_customers
4from
5 {{raw.shopify_example.customer}}
6group by
7 month
8order by
9 month
+------------+---------------+
| month | new_customers |
+------------+---------------+
| 2019-01-01 | 150 |
| 2019-02-01 | 200 |
| 2019-03-01 | 250 |
| 2019-04-01 | 300 |
| 2019-05-01 | 350 |
| 2019-06-01 | 400 |
| 2019-07-01 | 450 |
| 2019-08-01 | 500 |
| 2019-09-01 | 550 |
| 2019-10-01 | 600 |
| 2019-11-01 | 650 |
| 2019-12-01 | 700 |
+------------+---------------+
This SQL model allows you to track the growth of your customer base on a monthly basis, providing valuable insights into your business's performance. By selecting the date_trunc function, the SQL code groups customers by the month they were added to your database, making it easy to see trends in customer acquisition over time. The resulting output displays the number of new customers added each month, allowing you to identify which months saw the most growth and which months may need improvement. This SQL template is an essential tool for any business looking to track and optimize their customer acquisition strategy.