请教SQL语句
在一个表中有如下 如何转化到如下格式
type为类型
sum为该类型产量
…… type sum …type sumtyp1 sumtype2 …
1 100 1 100 0
2 200 2 0 200
1 200 1 200 0
2 300 2 0 300
… …
问题点数:0、回复次数:2Top
1 楼xluzhong(Ralph)回复于 2005-04-03 19:45:41 得分 0
alter table add sid int identity(1,1)
go
select type,sumtype1=(select case when type=1 then sum else 0 from tablename where sid=a.id),
sumtype2=(select case when type=2 then sum else 0 from tablename where sid=a.id)
from tablename aTop
2 楼yhever(yh)回复于 2005-04-03 20:01:19 得分 0
多谢
Top




