Your question is Active Subscriber Usage Query. Start with the requirements and the three 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.
AT&T needs a January 2026 usage report for active subscribers. Write a PostgreSQL query that combines subscriber and plan data with usage events.
INNER JOIN between subscribers and plans, so only subscribers with a valid plan are reported.LEFT JOIN to retain active subscribers with no January usage before aggregation.GROUP BY and HAVING to return only subscribers with at least 5,000 MB of January usage. Treat missing usage as zero, and order by usage descending.| Column | Type | Description |
|---|---|---|
| subscriber_idPK | INT | Unique AT&T subscriber identifier |
| subscriber_name | VARCHAR(100) | Subscriber's full name |
| plan_id | INT | Assigned wireless plan |
| status | VARCHAR(20) | Subscriber account status |
| Column | Type | Description |
|---|---|---|
| plan_idPK | INT | Unique wireless plan identifier |
| plan_name | VARCHAR(100) | AT&T wireless plan name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique usage event identifier |
| subscriber_id | INT | Subscriber associated with the event |
| usage_date | DATE | Date when data was consumed |
| data_mb | NUMERIC(10,2) | Data consumed in megabytes |