Sunday, February 18, 2024

Example of case and calculated field in sql

 select
InvoiceDate,
BillingAddress,
BillingCity,
total,
case
when total<2.00 then 'Baseline Purchase'
when total between 2.00 and 5.99 then 'Low Purchase'
when total between 7.00 and 15.00 then 'Target Purchase'
else 'Top Performer'
end as 'PurchaseType'
from Invoice
WHERE PurchaseType='Top Performer' and BillingAddress is not NULL
order by BillingCity

No comments:

Post a Comment