Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2002

    Unanswered: IF statement in SQL string

    I need to use an IF statement in a SQL string but i don't know if it's possible.

    i use an alias to select a value of C, this field is always
    greater then 0 but i want to transform it in negative or positive value depending the value of D...

    select A, B.....

    if D='55' then C else -C as E...

    from... etc.. etc...

    Is it possible insert IF statment in a select statement?
    How is the correct syntax?


  2. #2
    Join Date
    Feb 2002
    Try the following:

    select field1, field2, case when d="55" then "result 1"
    else "result2" end field3
    from table;

Posting Permissions

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