I am trying to write a query that returns the count of items whose price falls into certrain buckets:
For example if my table is:
item_name | price
i
A bit of modification of DRapp's code...
select
case when price >= 0 and price < 10 then " 0 - 10"
when price > 10 and price <= 50 then " 10+ - 50"
when price > 50 and price <= 100 then " 50+ - 100"
else "over 100"
end As PriceRange,
count(item_name) as ItemTotal
from YourTable
group by
case when price >= 0 and price < 10 then " 0 - 10"
when price > 10 and price <= 50 then " 10+ - 50"
when price > 50 and price <= 100 then " 50+ - 100"
else "over 100"
end;