可以完全用SQL做出报表!
1先写一个SELECT DESTINCT DEPARTMENT FROM SALES
2在程序中做一次循环,生成SQL
3执行,得到报表
sqldemo:
select sum(quantity) as depart1,0 as depart2,0 as depart3......
from (....)
union
select 0 as depart1,sum(quantity) as depart2,0 as depart3......
from (....)
select 0 as depart1,0 as depart2,sum(quantity) as depart3......
from (....)
group by 1,2,3......