一张起终点表,包含了不同人不同路径的许多数据,现在针对某一条起点i,终点j 的路径,对他的出行时间进行升序排序然后编号,想要求出编号位置位于全部编号的95%的出行时间,其求95分位数出行时间,程序如下,出现
FUNCTION TH95_TRAVEL_TIME 已编译
Errors: check compiler log 的错误,本人初学者,求大神解答疑惑,
create or replace function th95_travel_time(i number,j number)
return number
as
begin
declare cursor cu_travel_time is
select row_number() over (order by 出行时间) rn,出行时间 from 起终点表 where 地点A=i and 地点B=j;
row_number 起终点表.rn%type;
travel_time 起终点表.出行时间%type;
travel_time_95th 起终点表.出行时间%type;
odjilu 起终点表.rn%type;
begin
select count(*) into odjilu from 起终点表 where 地点A=i and 地点B=j; --将查询到的记录数目赋值给odjilu
open cu_travel_time;
fetch cu_travel_time into row_num,travel_time;
loop
if row_num=round(odjiuli*0.95,0) then
travel_time_95th:=travel_time;
exit;
end if;
fetch cu_travel_time into row_num,travel_time;
end loop;
close cu_travel_time;
return travel_time_95th;
end;
end th95_travel_time;
#6
该回复于2015-05-28 17:49:51被管理员删除
#7
SELECT percentile_cont(0.95) within GROUP( ORDER BY 工资) as p95 from 表