select @return= case @per when @per>80 then 5 when @per>60 then 4 when @per>40 then 3 when @per>20 then 1 else 0 end
now this query returns this error: Msg 102, Level 15, State 1, Procedure Findpoints, Line 10 Incorrect syntax near '>'. Msg 102, Level 15, State 1, Procedure Findpoints, Line 18 Incorrect syntax near 'end'.
select @return= (case when @per>80 then 5 when @per <=80 AND @per>60 then 4 when @per <=60 AND @per>40 then 3 when @per <=40 AND @per>20 then 1 else 0 end)
declare @return int declare @per int set @per=25 select @return=( case when @per>80 then 5 when @per>60 then 4 when @per>40 then 3 when @per>20 then 1 else 0 end) select @return
result ----------- 1 (1 row(s) affected)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)