Error

  • I am not sure why I am getting an error on query. Below is a subset of query that is causing an error. without this case statement the query works fine.

    Select col1,col2,col3 (This works fine)

    col3 has a rate value which ranges from 0.001 to 0.999

    I need to alter the query and add the following case statement - but it is not working. I need col3 to

    return .7 if the value of col3 is greater then .7

    Select col1, col2,col3

    case col3

    when > 0.7 then 0.7 else col3 End

    Thanks

  • Please post the error message. My guess is the data types of the column and the case are different?

  • I find the column name is incorrectly mentioned

    Select col1, col2,col3 =

    case col3 when > 0.7 then 0.7 else col3 End

    That "equals" sign was missing.

    Is that it or am i missing something obvious?

  • Here is the error message - thanks.

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near '>'.

  • ColdCoffee (3/23/2012)


    I find the column name is incorrectly mentioned

    Select col1, col2,col3 =

    case col3 when > 0.7 then 0.7 else col3 End

    That "equals" sign was missing.

    Is that it or am i missing something obvious?

    case when col3 > 0.7 then 0.7 else col3 end

  • Thanks ColdCoffee - the equal sign was the issue.

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

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