Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: sorting in oracle?

Re: sorting in oracle?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 12 Aug 1998 15:46:01 GMT
Message-ID: <35d6b882.10614262@192.86.155.100>


A copy of this was sent to iancrozier_at_aol.com (Iancrozier) (if that email address didn't require changing) On 12 Aug 1998 14:12:30 GMT, you wrote:

>I have a need to do the following
>In table T, I have three columns A, B, and C
>B has several numeric values for each value of A, some times the same value
>e.g.
>A=1234, B=200,200,300,400,600,600
>
>What I need to do is the following ( in this example )
>where B=600, set C=1
>where B=400, set C=2
>where B=300, set C=3
>where B=200, set C=4
>
>There are many values of B, so I have to do a comparison of different values of
>B for every value of A. Can I do this in SQL?
>
>Thanks in advance.
>

update T

   set C = decode( b, 600, 1, 
                      400, 2,
                      300, 3,
                      200, 4 );


 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Aug 12 1998 - 10:46:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US