【发布时间】:2014-08-14 17:20:10
【问题描述】:
我正在尝试在 Postgres 中创建一个函数,如下所示:
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;
但我收到以下错误:
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
我哪里错了?
【问题讨论】:
标签: sql postgresql user-defined-functions