我一直收到这个错误
无法将视图列"百分比"的数据类型从整数更改为双精度
我有一个函数调用findIntl()它返回一个浮点数
create or replace function findIntl(integer) returns float as $$
select cast(count(*) as float)
from students s
join program_enrolments pe on (s.id = pe.student)
where s.stype = 'intl' and pe.semester = $1;
$$ language sql;
Run Code Online (Sandbox Code Playgroud)
我在名为findPercent的视图中使用返回的值
create or replace view findPercent(semester, percent) as
select q6(s.id), findIntl(s.id)
from semesters s
where s.id = id and s.term ~ 'S' and s.year >= 2004;
Run Code Online (Sandbox Code Playgroud)
如果我findIntl()用另一列值替换它完全正常,但findIntl()它什么时候会说cannot change data type of view column "percent" from integer …