|
发表于 2022-1-18 20:27
来自手机
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
create temp table aa as select rowid old_rowid,* from 现金日报多账户三栏明细账 order by 户名,记账日期 COLLATE NATURAL_CMP;create temp table bb as with recursive under_alice (old_rowid,rowid,记账日期,户名,收入金额,支出金额,期初余额,期末余额) as (select old_rowid,rowid,记账日期,户名,收入金额,支出金额,0,收入金额-支出金额 期末余额 from aa where rowid=1 union select a.old_rowid,a.rowid,a.记账日期,a.户名,a.收入金额,a.支出金额,(case when a.户名 like under_alice.户名 then under_alice.期末余额 else 0 end) 期初余额,(case when a.户名 like under_alice.户名 then under_alice.期末余额+a.收入金额-a.支出金额 else a.收入金额-a.支出金额 end) 期末余额 from aa a join under_alice on a.rowid-1=under_alice.rowid) select * from under_alice;select substr(记账日期,1,4) 年,regreplace('/\d\/(\d+\/\d+)/','\1',记账日期) 月,记账日期,户名,期初余额,收入金额,支出金额,期末余额 from bb order by old_rowid;select substr(记账日期,1,4) 年,regreplace('/\d\/(\d+\/\d+)/','\1',记账日期) 月,记账日期,户名,期初余额,收入金额,支出金额,期末余额 from bb order by rowid;
|
|