Your question is CTE Purchases Query. Start with the requirements and the two tables 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.
Capgemini Engineering wants to identify customers who are engaging frequently with its digital commerce services. Write a PostgreSQL query using CTEs to find customers with more than three purchases during the last 30 days.
For reproducible testing, interpret the period relative to PostgreSQL's CURRENT_DATE. The sample data is positioned around the current date used for evaluation.
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's full name |
| VARCHAR(255) | Customer email address |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| customer_id | INT | Customer who made the purchase |
| purchase_timestamp | TIMESTAMPTZ | Date and time of the purchase |
| amount | NUMERIC(10,2) | Purchase amount |