Use a case expression in scalar valued function
I want to get one value from a function using a case expression. I tried the following but it does not work:
CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(
@Period INT
)
RETURNS int
AS
BEGIN
select case @Period
when 1 then 1
when @Period >1 and @Period <=7 then 1
when @Period >7 and @Period <=30 then 1
when @Period >30 and @Period<=90 then 1
when @Period >90 and @Period <=180 then 1
when @Period >180 and @Period <=360 then 1
else 0
end
return @Period
END