PGSQL分組累加SQL

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;

按項目名稱和月份分組,按計劃金額與實際金額累加

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章