Your question is SQL Window Functions for Top Customers. 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.
Genesys Cloud Analytics needs a ranked view of customers based on completed subscription revenue. Write a PostgreSQL query that aggregates revenue per customer and uses a window function to return the top 10 customers.
customers to orders using customer_id.status = 'completed'.customer_id.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(120) | Customer account name |
| segment | VARCHAR(40) | Customer segment |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | References customers.customer_id |
| revenue | NUMERIC(12,2) | Revenue recognized for the order |
| status | VARCHAR(20) | Order processing status |
| order_date | DATE | Date the order was placed |