OK, well here's the two variations for SQL Server 2005:
The first version looks like what you want, except that when_expression needs to be a value (of the same type as the input_) rather than a condition.. which means you need to use the second, so like this:Code:Simple CASE function: CASE input_expression WHEN when_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END Searched CASE function: CASE WHEN Boolean_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END
Code:, CASE WHEN Total > 100 THEN 100 ELSE Total END AS Reward




Reply With Quote