I try to create function
CREATE OR REPLACE FUNCTION public.my_sql_function3(IN inputval integer)
RETURNS TABLE("ID" integer, name character varying, cnt integer) AS
$BODY$
select t.id, t.name, CAST(count(*) AS INTEGER)
from test t
where t.id < inputval
group by t.id, t.name $BODY$
LANGUAGE plpgsql VOLATILE;
and get error:
ERROR: syntax error at or near "select"
LINE 4: select t.id, t.name, CAST(count(*) AS INTEGER)
How to fix it?