Mysql查询数据包含 合计列

select (case org_order when 003 then (@i:=@i+1) else (@i:=@i+3) end) order_index,z.* from (select case when t.org_order is null then ‘合计’ else (
select a.org_name from ct_organization a where a.org_order =t.org_order) end as org_orders, min(t.org_order) as org_order,t.year,t.date,t.create_time,
sum(t.project_num) as project_num,
sum(t.new_dev_num) as new_dev_num,
sum(t.cut_line_num) as cut_line_num,
sum(t.infrastruc_num) as infrastruc_num,
sum(t.techni_trans_num) as techni_trans_num,
sum(t.maintenance_num) as maintenance_num,
t.org_name

from bdc_drawmananger_year t
GROUP BY left(t.org_order,6),t.org_order
WITH ROLLUP) z,(select @i:=0)m

你可能感兴趣的:(Mysql查询数据包含 合计列)