2011-10-10 107 views

回答

2

Writen爲MSSQL:

declare @t table(field varchar(20), date date) 

insert @t values('X', '2010-01-01') 
insert @t values('X', '2010-01-02') 
insert @t values('X', '2010-01-03') 
insert @t values('Y', '2010-01-04') 
insert @t values('Y', '2010-01-05') 
insert @t values('Y', '2010-01-06') 


select b.* from @t a join @t b on dateadd(day, 1, a.date) = b.date 
and a.field <> b.field 

結果:

field    date 
-------------------- ---------- 
Y     2010-01-04 

還應針對Sybase工作,如果你與你的表格代替@t而忽略了測試數據