[阅读: 424] 2006-09-04 08:00:05
用个Join就可以搞定了
Create table T1
([TheDate] DateTime, [Value] int)
Go
insert into T1 values('2006-8-1', 100)
insert into T1 values('2006-8-2', 200)
insert into T1 values('2006-8-3', 300)
insert into T1 values('2006-8-5', 400)
insert into T1 values('2006-8-7', 220)
insert into T1 values('2006-8-8', 140)
Go
select A.TheDate, B.Value Today, C.Value Yesterday
from (select distinct TheDate from T1) A
left join (select TheDate, Value from T1) B
on A.TheDate=B.TheDate
left join (select dateadd(Day, 1, TheDate) as TheDate,Value from T1) C
on A.TheDate=C.TheDate
Go
夫习拳艺者,对已者十之七八,对人者,仅十之二三耳。拳艺之道,深无止境。得其浅者,一人敌,得其深者,何尝不万人敌耶!
我的Google Picasa相册
我的新BLOG