Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL ORDER BY Question
Apparently Paul Q <paulq_at_home.com> wrote:
>khs_at_netset.com wrote in message <37cdd18f.121019_at_news.netset.com>...
>>Ok, I want to include a column (lets call it X) in my ORDER BY clause
>>of a SELECT statement but I have a problem with the data.
>>
>>For column X:
>>Values '1' and '5' represent Army
>>Values '2' and '6' represent Navy
>>Values '3' and '7' represent Marines and
>>Values '4' and '8' represent AirForce
>decode('X',1,1,5,1,2,2,6,2,3,3,7,3,4,4,8,4) service
You could also have an x-to-service decoding table, and select service, not X.
table services:
X Service
1 Army
2 Navy
3 Marines
...
7 Marines
8 Airforce
SELECT s.service, t. ... FROM services s, yourtable t
WHERE s.X = t.X ORDER BY s.service
That would be a pretty general solution then.
--
Ken Tough
Received on Fri Sep 03 1999 - 04:46:55 CDT
![]() |
![]() |