At Northstar Commerce, the analytics team wants to identify the top-performing clients for each product based on completed sales. Write a SQL query to rank clients by total revenue within each product.
product_name and client_name using quantity * unit_price.| Column | Type | Description |
|---|---|---|
| client_idPK | INT | Unique client identifier |
| client_name | VARCHAR(100) | Client name |
| region | VARCHAR(50) | Client sales region |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product name |
| category | VARCHAR(50) | Product category |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| client_id | INT | References clients.client_id |
| product_id | INT | References products.product_id |
| order_date | DATE | Date the order was placed |
| quantity | INT | Number of units ordered |
| unit_price | DECIMAL(10,2) | Price per unit |
| status | VARCHAR(20) | Order status such as completed or cancelled |