我的表格包含partija_1
,partija_2
和date
列。
我应该发现partija_2
也在partija_1
列中,直到来
至不在partija_2
列中的partija_1
并从中获取日期并更新以前的链数据。
例如,1445033004937位于partija_1
,之后我看到partija_1
中的1445033003000,之后是partija_1
的1445033005000。最后我来到不在partija_1
的1445033006000,我应该从中获取日期并更新所有链链接的列的日期。
Partija_1 Partija_2 date
-------------------------------------------------------------------------
1445033005038 1445033004937 2016.04.30 should update in 2016.01.31
1445033004937 1445033003000 2016.03.31 should update in 2016.01.31
1445033003000 1445033005000 2016.02.28 should update in 2016.01.31
1445033005000 1445033006000 2016.01.31
5445033005038 5445033004937 2017.04.30 should update in 2017.01.31
5445033004937 5445033003000 2017.03.31 should update in 2017.01.31
5445033003000 5445033005000 2017.02.28 should update in 2017.01.31
5445033005000 5445033006000 2017.01.31
表结构是
create table #test(
Partija_1 varchar(40),
Partija_2 varchar(40),
date varchar(40)
)
表#test中的值为:
insert into #test
values('1445033005038','1445033004937','2016.04.30')
insert into #test
values('1445033004937','1445033003000','2016.03.31')
insert into #test
values('1445033003000','1445033005000','2016.02.28')
insert into #test
values('1445033005000','1445033006000','2016.01.31')
insert into #test
values('5445033005038','5445033004937','2017.04.30')
insert into #test
values('5445033004937','5445033003000','2017.03.31')
insert into #test
values('5445033003000','5445033005000','2017.02.28')
insert into #test
values('5445033005000','5445033006000','2017.01.31')
Result should be update date column, and output should be the following:
Partija 1 Partija 2 date
1445033005038 1445033004937 2016.01.31
1445033004937 1445033003000 2016.01.31
1445033003000 1445033005000 2016.01.31
1445033005000 1445033006000 2016.01.31
5445033005038 5445033004937 2017.01.31
5445033004937 5445033003000 2017.01.31
5445033003000 5445033005000 2017.01.31
5445033005000 5445033006000 2017.01.31