I have a table(offer) with three columns, id, product_id and price.
offer
-----
id (integer)
product_id (integer)
price (decimal)
I wanted to fire a SQL query which will return the number of offers between a price range. range should be like 0-1, 1-2, 2-3 etc
price_lower price_upper number_of_offers
-------------------------------------------------------------
0 1 4
1 2 1
2 3 0
3 4 6
4 5 2
... etc
I did this to get the number of offers between 0 and 1
SELECT * FROM offer WHERE price BETWEEN 0 and 1;
What should be the query to get desired result.
Any sort of help will be appreciated. Thanks in advance.