Your question is SQL for Active Users. 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.
Swiggy wants to measure the share of registered users who were recently active through an order. Using the tables below, write a PostgreSQL query to calculate this percentage as of 2025-02-15.
The 30-day period is inclusive of 2025-01-17 and 2025-02-15.
users as the denominator, including users with no orders.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique Swiggy user identifier |
| user_name | VARCHAR(100) | User display name |
| city | VARCHAR(50) | User's registered city |
| Column | Type | Description |
|---|---|---|
| order_idPK | INTEGER | Unique order identifier |
| user_id | INTEGER | User who placed the order |
| order_date | DATE | Date the order was placed |
| order_status | VARCHAR(20) | Current order status |