v_year_hb 视图如下select v1.nf,v1.yavg,v1.canton_Id,v1.sp_id, ((v1.yavg-v2.yavg)/v2.yavg)*100 yhb ,c.mc,cpfl.pm from v_year_avg v1 left join v_year_avg v2 on v1.nf = v2.nf + 1 and v1.canton_Id = v2.canton_Id and v1.sp_id = v2.sp_id left join canton c on c.id = v1.canton_Id left join JGJK_CPFL cpfl on v1.sp_id = cpfl.id;
数据量较大,建议使用分析函数实现分页 SELECT * FROM ( SELECT row_number()over(order by rq desc,scordernum,bigpmordernum,pmordernum) rn, 'pfsc' as type,vsc.* FROM V_PFSC vsc WHERE id is not null ) WHERE rn>=1 and rn<=5
SELECT * FROM (SELECT rownum rn,pageContext.* FROM ( 我的sql ) pageContext) WHERE rn>=1 and rn<=5 外面的是程序封装的,不好改。。
from v_year_avg v1
left join v_year_avg v2
on v1.nf = v2.nf + 1
and v1.canton_Id = v2.canton_Id
and v1.sp_id = v2.sp_id
left join canton c on c.id = v1.canton_Id
left join JGJK_CPFL cpfl on v1.sp_id = cpfl.id;
SELECT * FROM (
SELECT row_number()over(order by rq desc,scordernum,bigpmordernum,pmordernum) rn,
'pfsc' as type,vsc.* FROM V_PFSC vsc WHERE id is not null
) WHERE rn>=1 and rn<=5