I need to rewrite a SQL scalar function which is called in power bi reports
how can I achieve the following in snowflake?
create function test (@input varchar(10)) returns varchar ( declare @text varchar(50) declare @cnt int select @cnt = max(key) from tbl;
if @input = 'table1' begin select @text = text from table1 --statements will be different based on input passed and is from tables end
if @input = 'table12' begin select @text = text from table12 where id = @cnt end
...
return @text )
Can you please share some examples where we can declare /set variables and also execute sql statements based on input parameter passed ?
Thanks, Jo