赞
踩
对所有数据进行查询,并对其中的department字段值相同的值进行累加查询。
SELECT `department` , sum( `item_real` ) , sum( `item_budget` ) , sum( `tuisuan` ) FROM `budget_all` GROUP BY `department`
仅仅对department=dd,dt进行求和:
select department,sum(item_real),sum(item_budget),sum(tuisuan) from budget_all where department='dt' or department='dd' group by department
求和原型:
select department,sum(item_real),sum(item_budget),sum(tuisuan) from tb group by department