orcale:
select a.vseq,a.declaredate as declaredate1,b.declaredate as declaredate2
from
(select vseq,declaredate,rownum as row from mac505 order by vseq,declaredate)a,
(select vseq,declaredate,rownum as row from mac505 order by vseq,declaredate)b
where a.vseq=b.vseq and a.row+1=b.row and a.declaredate+1000<b.declaredate
sql server由于只有2005以上版本才有row_number()函数,所以如下脚本只能用在2005以上版本中
select a.vseq,a.declaredate as declaredate1,b.declaredate as declaredate2
from
(select vseq,declaredate,row_number() orver (order by vseq,declaredate) as row from mac505 )a,
(select vseq,declaredate,row_number() orver (order by vseq,declaredate) as row from mac505 )b
where a.vseq=b.vseq and a.row+1=b.row and a.declaredate+1000<b.declaredate
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)