我一直在抨击这个问题已经有一段时间了,而且进展不快;数据必须保持在行级别。
我想保留最早到达的数据,重复有效。Load1 代表一个批次ID。并非所有值都有重复项
我想退货
Code1 Code2 Code3 Load1 LoadTime
a1 a1 a1 1 2013-09-10
a1 a1 a1 1 2013-09-10
a1 a1 a1 1 2013-09-10
a2 a1 a1 2 2013-09-12
a1 a2 a1 3 2013-09-13
a1 a2 a1 3 2013-09-13
有什么建议么?
CREATE TABLE #Test (
Code1 varchar(10),
Code2 varchar(10),
Code3 varchar(10),
Load1 varchar(10),
LoadTime DATE
)
INSERT INTO #Test
VALUES ('a1','a1','a1','1','2013-09-10') --Keep
INSERT INTO #Test
VALUES ('a1','a1','a1','1','2013-09-10') --Keep
INSERT INTO #Test
VALUES ('a1','a1','a1','1','2013-09-10') --Keep
INSERT INTO #Test
VALUES ('a1','a1','a1','2','2013-09-11') --Delete
INSERT INTO #Test
VALUES ('a2','a1','a1','2','2013-09-12') --Keep
INSERT INTO #Test
VALUES ('a2','a1','a1','3','2013-09-13') --Delete
INSERT INTO #Test
VALUES ('a1','a2','a1','3','2013-09-13') --Keep
INSERT INTO #Test
VALUES ('a1','a2','a1','3','2013-09-13') --Keep
INSERT INTO #Test
VALUES ('a1','a2','a1','4','2013-09-13')-- Delete
INSERT INTO #Test
VALUES ('a1','a2','a1','4','2013-09-13')-- Delete