Management wants to compare the sales performance of support representatives. Calculate each rep's customer count, invoice count, total revenue, average invoice value, and rank them.
| Column | Type |
|---|---|
| EmployeeId | INTEGER (Primary Key) |
| LastName | TEXT |
| FirstName | TEXT |
| Title | TEXT |
| ReportsTo | INTEGER (Self-referencing Foreign Key) |
| BirthDate | TIMESTAMP |
| HireDate | TIMESTAMP |
| Address | TEXT |
| City | TEXT |
| State | TEXT |
| Country | TEXT |
| PostalCode | TEXT |
| Phone | TEXT |
| Fax | TEXT |
| TEXT |
| Column | Type |
|---|---|
| CustomerId | INTEGER (Primary Key) |
| FirstName | TEXT |
| LastName | TEXT |
| Company | TEXT |
| Address | TEXT |
| City | TEXT |
| State | TEXT |
| Country | TEXT |
| PostalCode | TEXT |
| Phone | TEXT |
| Fax | TEXT |
| TEXT | |
| SupportRepId | INTEGER (Foreign Key → Employee.EmployeeId) |
| Column | Type |
|---|---|
| InvoiceId | INTEGER (Primary Key) |
| CustomerId | INTEGER (Foreign Key → Customer.CustomerId) |
| InvoiceDate | TIMESTAMP |
| BillingAddress | TEXT |
| BillingCity | TEXT |
| BillingState | TEXT |
| BillingCountry | TEXT |
| BillingPostalCode | TEXT |
| Total | NUMERIC(10,2) |
CustomerCount, InvoiceCount, TotalRevenue, AvgInvoiceRANK() to rank by TotalRevenue descendingReady to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.
Run your code to see the result here.