SQL2000二维显示的一些有关问题
SQL2000二维显示的一些问题
有表如下:
通过语句:
出现如下效果:
但是希望出现如下效果:
也就是说,OrderNo没有出现的物料,下面是出现--,否则就是空白,请问该怎么修改代码?
请诸位不吝赐教,多谢了!
------解决方案--------------------
试试
有表如下:
OrderNo DescCh TrimTypeID Area SecondTrim UpdateDateTime
136878B 紐 4 前期 NULL NULL
136878B 紙箱 9 後期 NULL NULL
136878B 掛牌 8 後期 NULL NULL
136878B 貼紙 10 後期 NULL NULL
136878B 嘜頭 1 後期 NULL NULL
136878B 線 2 前期 NULL NULL
136878B 膠袋 7 後期 NULL NULL
136878B 織帶 3 前期 NULL NULL
136987A 紙箱 9 後期 NULL NULL
136987A 掛牌 8 後期 NULL NULL
136987A 貼紙 10 後期 NULL NULL
136987A 線 2 前期 NULL NULL
136987A 膠袋 7 後期 NULL NULL
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-27
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Pre) 2013-12-28
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137253A 貼紙 10 後期 膠袋貼紙(Bul) 2013-12-31
137349A 扣針 11 前期 NULL NULL
通过语句:
Declare @sql Varchar(8000)
Set @sql='Select OrderNo'
select @sql=@sql+',['+dd+']=max(case DescCh when '''+dd+''' then UpdateDateTime else '''' end)'
from (select distinct dd=DescCh from #a) ss
Set @sql=@sql+'From #a Group by OrderNo'
exec(@sql)
出现如下效果:
OrderNo 扣針 鈕 紙箱 掛牌 貼紙 嘜頭 線 膠袋 織帶
136878B
136987A
137253A 2013-12-31
137349A NULL
但是希望出现如下效果:
OrderNo 扣針 鈕 紙箱 掛牌 貼紙 嘜頭 線 膠袋 織帶
136878B --
136987A -- -- -- --
137253A -- -- -- -- 2013-12-31 -- -- -- --
137349A NULL -- -- -- -- -- -- -- --
也就是说,OrderNo没有出现的物料,下面是出现--,否则就是空白,请问该怎么修改代码?
请诸位不吝赐教,多谢了!
------解决方案--------------------
试试
Declare @sql Varchar(8000)
Set @sql='Select OrderNo'
select @sql=@sql+',['+dd+']=isnull(max(case DescCh when '''+dd+''' then UpdateDateTime else '''' end),''--'')'
from (select distinct dd=DescCh from #a) ss
Set @sql=@sql+'From #a Group by OrderNo'
exec(@sql)