create function fnamount(@value int) returns int as
begin
return (select
case @value
when 0 then 0
when 1 then 50
when 2 then 90
when 3 then 150
when 4 then 300
when 5 then 500
else 1000
end )
end
select (case dbo.fnamount(1) when 0 then 'เติมเงินผิดพลาด (0)'
else cast(dbo.fnamount(1) + 100 as varchar(20)) end) as Result
from Tblxxx Order by amount desc