创建一个原始数据视图:
CREATE OR REPLACE VIEW v_t AS
SELECT 1000 AS ID,'预缴费用' AS NAME,30000 AS money FROM dual
UNION ALL
SELECT 7782 AS ID,'支出1' AS NAME,3450 AS money FROM dual
UNION ALL
SELECT 7839 AS ID,'支出2' AS NAME,6000 AS money FROM dual
UNION ALL
SELECT 7934 AS ID,'支出3' AS NAME,2300 AS money FROM dual;
列出流水账每一笔钱支出后的余额
SELECT a.*,SUM(CASE WHEN id=1000 THEN a.money ELSE -a.money END)
OVER(ORDER BY ID) AS remaining FROM v_t a ORDER BY ID;
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于