I am trying to create a function in Postgres as follows:
Create function Samplefunc()
returns resultdata( Tested int, Score int,
Growth int) as
$BODY$
Select
Count(distinct student_id) Tested,
Cast(Avg(R.raw_score) as Int) Score,
Avg(R.growth) as Growth
from results R
where R.id=1 and test_id='ME04';
$BODY$
LANGUAGE sql;
But I am getting the following error:
ERROR: syntax error at or near "int"
LINE 2: returns resultdata( NTested int, RawScore int,
^
********** Error **********
ERROR: syntax error at or near "int"
SQL state: 42601
Character: 59
Where am I going wrong?