Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help with SQL
A few questions:
Are these variables (VAR1 and VAR2) in the same table?
Are these variables the same type?
Can the variables be NULL (either or both)?
What should COL_A be if the VAR1 is equal to VAR2?
Assuming that the variables are in the same table, neither variable can be NULL and that 'VAL_1' is the answer if VAR1 is equal to VAR2; then this code should work for you.
UPDATE mytable SET COL_A =
DECODE(GREATEST(VAR1,VAR2),var1,'VAL_1','VAL_2')
HTH
James
In article <371b5ad3_at_newsread3.dircon.co.uk>,
"Paul Wiles" <john_at_adzi.com> wrote:
> I wish to write a SINGLE block of SQL which does the following:
>
> update TABLE
> set COL_A = ('VAL_1' if VAR1 > VAR2,'VAL_2 if VAR1 < VAR2)
>
> Can someone please help me with this?
>
> Thanks
>
> Paul
>
>
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Apr 19 1999 - 13:04:55 CDT
![]() |
![]() |