IF in Select

  • Hi all

    following Query

    SELECT EmpName As EName

    IF (BasicPay>5000, "OVER","lOW"), AS Result

    FROM EmpSalary

    The Result is following in Error

    Line 2: Incorrect syntax near ','.

    hope somebody help me

    Thanks

  • Use Case statment

    SELECT EmpName As EName

    case when BasicPay>5000 then 'OVER else 'lOW' end AS Result

    FROM EmpSalary

  • Use Case statment

    SELECT EmpName As EName

    case when BasicPay>5000 then 'OVER else 'lOW' end AS Result

    FROM EmpSalary

    Its also not working

    Incorrect syntax near the keyword 'case'.

  • iamidress (2/21/2012)


    Use Case statment

    SELECT EmpName As EName

    case when BasicPay>5000 then 'OVER else 'lOW' end AS Result

    FROM EmpSalary

    Its also not working

    Incorrect syntax near the keyword 'case'.

    Just a comma and an apostrophe missed off:

    try this:

    SELECT EmpName As EName,

    case when BasicPay>5000 then 'OVER' else 'lOW' end AS Result

    FROM EmpSalary

  • many many Thanks

    Its Working

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply