0
点赞
收藏
分享

微信扫一扫

PGSQL分组累加SQL

王小沫 2023-01-09 阅读 108

select *,
(select sum(planmoney) as pl from table as inn where project_id = table.project_id and inn.date <= table.date) as plan_total,
(select sum(actualmoney) as act from table as inn where project_id = table.project_id and inn.date <= table.date) as act_total
from table order by project_name,date;

按项目名称和月份分组,按计划金额与实际金额累加


举报

相关推荐

0 条评论