The CRM team wants to segment customers into value tiers based on their lifetime spending. Classify each customer as Platinum, Gold, Silver, or Bronze using quartiles.
| 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) |
NTILE(4) to split customers into quartiles by spendingCustomerName, Country, TotalOrders, LifetimeValue, TierReady 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.