I am very much new to Amazon redshift. I am trying to create the UDF function to create column aggregation by adding multiple columns, here is what I am tried
CREATE OR REPLACE FUNCTION pp_calc(identifier varchar(100),table_name varchar(100))
RETURNS float
stable
as $$
BEGIN
IF identifier ='OC' THEN
EXECUTE 'SELECT identifier'||_1 + || 'identifier' ||_2 || 'FROM ' || table_name /* I want to return this addition result */
ELSE
'SELECT identifier'||_1 + || 'identifier' ||_2 || 'FROM ' || table_name
END IF;
END;
$$ LANGUAGE sql;
Errors I am getting near return statement. I am sure there is something wrong with syntax. I want to pass the indentifer as parameter based on parameter I want to add columns.
language sqlfunctions