with H as( select F.PRO_DATE, F.PRO_NAME, F.PRO_AMO, lag(pro_amo, 3, null) over(order by pro_name ) as 上年末 from FR_202203Last3YSKDC_TABLE F ) select * from H where h.pro_amo is not null and h.上年末 is not null 用完分析函数 查询出的结果比较分散 所以用了with as 还需要计算pro_amo-上年末与(pro_amo-上年末)/上年末 |