DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Decode

  1. #1
    Join Date
    Feb 2002
    Posts
    267

    Decode

    Hi,

    How can i use Decode function

    I have columns Start_Date and End_date.

    If End_Date is > Start_Date, i want to substitute with the SYSDATE.
    I am using DECODE function, but getting errors...



    Select START_DATE,
    decode(END_DATE,(END_DATE>SYSDATE),sysdate,END_DATE)
    FROM
    Date_Table where TECH_NO=64783;

    I am getting paranthesis error....

    Can i use > and less than symbol in DECODE ???


    Regards
    Sonia

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    You need to use case:

    Select
    Case
    When END_DATE>SYSDATE Then SYSDATE
    Else END_DATE
    End
    From . . . .


    P.S. you can do it with decode & sign(END_DATE-SYSDATE)
    Last edited by DaPi; 01-12-2004 at 09:55 AM.

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