select Field,OtherField from(
select Field,OtherField,a Name from table
where Field<=3
union all
select Field,OtherField,b Name from table
where Field>3 and Field<=6
union all
select Field,OtherField,c Name from table
where Field>6)
group by Name
select Field,OtherField,a Name from table
where Field<=3
union all
select Field,OtherField,b Name from table
where Field>3 and Field<=6
union all
select Field,OtherField,c Name from table
where Field>6)
group by Name
---------- ----------
1 1
2 1
5 1
4 1
5 1
6 2
8 2
9 2
10 2
6 2
8 2 ID CASE
---------- ----------
9 2
10 2
7 2
decode(sign(field-7),-1,2,
decode(sign(field-11),-1,3,0))) from tablename;最后一个零表示字段值不在[1~10]之间