Reputation: 319
Just Sample Table : Cus_fi.
Can i
SELECT SUM(dollar,euro,pound) FROM cus_fi ; in 1 query.
And Show Result by age range like this.
20 - 25 1500 410 166
26 - 30 5300 2000 584
Thank for help student really want to known.
Upvotes: 0
Views: 74
Reputation: 4737
Try this one:
SELECT age, SUM(dollar) AS Total_Dollar, SUM(Euro) AS Total_Euro,
SUM(Pound) AS Total_Pound
FROM cus_fi GROUP BY age
EDIT:
SELECT CONCAT(2*floor(age/2), '-', 2*floor(age/2) + 2) as `age_range`, SUM(dollar) AS Total_Dollar, SUM(Euro) AS Total_Euro,
SUM(Pound) AS Total_Pound
FROM cus_fi GROUP BY 1 ORDER BY age
Upvotes: 1
Reputation: 125630
select
round(age / 5) * 5 - 4,
round(age / 5) * 5,
SUM(dollar),
SUM(euro)
FROM TEST
GROUP BY round(age / 5)
You can extend it with more columns. See DEMO: http://sqlfiddle.com/#!2/160bb/15
Upvotes: 3