|
发表于 2011-10-29 11:03:24
|
显示全部楼层
Re:动态滴列名
SQL code select 大类,产品代码,计量单位,
sum(case when 时间='2010-10' then 期初 else 0 end) [2010-10期初],
sum(case when 时间='2010-10' then 收入 else 0 end) [2010-10收入],
sum(case when 时间='2010-10' then 发出 else 0 end) [2010-10发出],
sum(case when 时间='2010-10' then 结存 else 0 end) [2010-10结存],
sum(case when 时间='2010-11' then 期初 else 0 end) [2010-11期初],
sum(case when 时间='2010-11' then 收入 else 0 end) [2010-11收入],
sum(case when 时间='2010-11' then 发出 else 0 end) [2010-11发出],
sum(case when 时间='2010-11' then 结存 else 0 end) [2010-11结存]
from tb group by 大类,产品代码,计量单位 |
|