views:

42

answers:

2

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?

+1  A: 
select min(rate), sum(amount) from interest group by floor(rate / 0.25);
Matthew Flaschen
if i want to get interest rate along with amount,then what to do
+1  A: 
SELECT FLOOR(interest*4)/4 AS interest_rate, SUM(amount) AS amount_sum
FROM table_name
GROUP BY interest_rate;
VeeArr