Re: SQL group by a range?
From: srivenu <srivenu_at_hotmail.com>
Date: 26 Feb 2002 21:23:33 -0800
Message-ID: <1a68177.0202262123.a057c86_at_posting.google.com>
from "table_name"
group decode(trunc(grade/10),
Date: 26 Feb 2002 21:23:33 -0800
Message-ID: <1a68177.0202262123.a057c86_at_posting.google.com>
Try this
select decode(trunc(grade/10),
0,'0-9', 1,'10-19', 2,'20-29', 3,'30-39', 4,'40-49', 5,'50-59', 6,'60-69', 7,'70-79', 8,'80-89', 9,'90-100', 10,'100') Grade Range, count(*) No of Students
from "table_name"
group decode(trunc(grade/10),
0,'0-9', 1,'10-19', 2,'20-29', 3,'30-39', 4,'40-49', 5,'50-59', 6,'60-69', 7,'70-79', 8,'80-89', 9,'90-100', 10,'100');
neo_thinker_at_hotmail.com (Neothinker) wrote in message news:<d351ed4f.0202261405.7a3ef902_at_posting.google.com>...
> I am trying to create a query that will tally the number of students
> with a grade from 90 to 100, 80 to 89, 70 to 79 ,... etc. So if I have
> a table that just had a "STUDENT" column and a "GRADE" column, what
> generic SQL could I use? As far as I know, the GROUP BY only accepts a
> column name, not an expression.
Received on Wed Feb 27 2002 - 06:23:33 CET