日期:2014-05-18 浏览次数:20597 次
--原始数据:#asset create table #asset(times varchar(7),number int) insert #asset select '2006-1',5 union all select '2006-2',10 union all select '2006-5',8 union all select '2006-8',16 union all select '2006-12',9 select top 12 mon=identity(int,1,1) into #mon from syscolumns select times='2006-'+ltrim(a.mon),number=isnull(b.number,0) from #mon a left join #asset b on '2006-'+ltrim(a.mon)=b.times /* times number ----------------- ----------- 2006-1 5 2006-2 10 2006-3 0 2006-4 0 2006-5 8 2006-6 0 2006-7 0 2006-8 16 2006-9 0 2006-10 0 2006-11 0 2006-12 9 */ drop table #asset,#mon