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: Help with SQL

Re: Help with SQL

From: James <james_lorenzen_at_allianzlife.com>
Date: Mon, 19 Apr 1999 18:04:55 GMT
Message-ID: <7ffr81$n4m$1@nnrp1.dejanews.com>


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

Original text of this message

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