decode?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: decode?

  1. #1
    Join Date
    Nov 2000
    Posts
    440

    decode?

    What is the way to do this in 1 select statement

    if field1 < feild2 then
    return(field1)
    else
    return(field2)
    end if;

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Select LEAST(f1,f2)

  3. #3
    Join Date
    Jan 2003
    Location
    Hull, UK
    Posts
    220
    With Decode its like this

    SELECT
    DECODE(field1,NULL,'NULL',field1),
    DECODE((1-SIGN(1-SIGN(field1 - field2))),1,field1,
    NULL, 'Value is null',
    field2) result
    FROM ur_table

    Srini

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    If you need a more general solution than LEAST, use CASE. It's more intuitive than DECODE and it's ANSI.

    Srini - you must be joking, or are you?

  5. #5
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Or how about: LEAST(NVL(f1,f2),NVL(f2,f1))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width