Reputation: 171
i have interest rate and amount in a table where interest rate are ranged in different values like 4.5,4.6,5.2,5.6 etc.
i want to get sum of amounts classified by interest rate where interest rate will be separated by .25.
for example all amount having interest rate 1.25,1.3,1.4 will be in one group and 1.5,1.67,1.9 will be in another group
how can i write the query?
Upvotes: 0
Views: 69
Reputation: 6178
SELECT FLOOR(interest*4)/4 AS interest_rate, SUM(amount) AS amount_sum
FROM table_name
GROUP BY interest_rate;
Upvotes: 1
Reputation: 284786
select min(rate), sum(amount) from interest group by floor(rate / 0.25);
Upvotes: 1