SELECT 时间, LAG(累计现金) OVER (ORDER BY 时间) AS 上日现金, LAG(累计银行) OVER (ORDER BY 时间) AS 上日银行, LAG(累计余额) OVER (ORDER BY 时间) AS 上日余额 FROM (SELECT 时间, SUM(现金收入) OVER (ORDER BY 时间) AS 累计现金, SUM(银行收入) OVER (ORDER BY 时间) AS 累计银行, SUM(现金收入 + 银行收入 - 现金支出 - 银行支出) OVER (ORDER BY 时间) AS 累计余额 FROM 日报 WHERE itemid = 'aca15c09-ee93-494c-9fb2-d440e3ae5738' AND 时间 >'2023-08-30') AS C 因为我只有这几天有数据,所以偏移出来以后只有这几天的偏移数据,我想呈现的是2023-10-12 10-11 都有数据该怎么修改lag函数 |