Split invoice-line revenue into standard (UnitPrice = 0.99) vs premium (UnitPrice = 1.99) per billing country.
| Column | Type |
|---|---|
| InvoiceId | INTEGER (PK) |
| CustomerId | INTEGER (FK) |
| InvoiceDate | TIMESTAMP NOT NULL |
| BillingCountry | TEXT |
| Total | NUMERIC(10,2) NOT NULL |
| Column | Type |
|---|---|
| InvoiceLineId | INTEGER (PK) |
| InvoiceId | INTEGER (FK) |
| TrackId | INTEGER (FK) |
| UnitPrice | NUMERIC(10,2) NOT NULL |
| Quantity | INTEGER NOT NULL |
BillingCountry, StandardRevenue, PremiumRevenue, PremiumShare (premium / total, as percent rounded to 2 decimals)SUM(CASE WHEN ... THEN ... END) for the splitReady 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.