March 23, 2012 at 6:25 pm
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
March 23, 2012 at 6:46 pm
Please post the error message. My guess is the data types of the column and the case are different?
March 23, 2012 at 8:27 pm
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?
March 23, 2012 at 9:52 pm
Here is the error message - thanks.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '>'.
March 23, 2012 at 10:19 pm
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
March 24, 2012 at 12:20 pm
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