求SQL语句,删除重复的数据只留第一笔
请问如何将表A,同一ID删除重复的数据,只留下第一笔数据,并得到如表B的结果
表A:
ID DATE I1 I2 I3 I4 I5
A1 02/06 (857)
A1 06/11 (857)
A1 08/02 (855) (857) (855,857)
A1 08/05 (851) (857) (874) (851,857),(851,874),(857,874) (851,857,874)
A1 10/21 (855) (857) (873) (855,857),(855,873),(857,873) (855,857,873)
A1 10/25 (855) (857) (873) (855,857),(855,873),(857,873) (855,857,873)
B1 ....
结果如下:
ID DATE I1 I2 I3 I4 I5
A1 02/06 (857)
A1 06/11
A1 08/02 (855) (855,857)
A1 08/05 (851) (874) (851,857),(851,874),(857,874) (851,857,874)
A1 10/21 (873) (855,873),(857,873) (855,857,873)
A1 10/25
B1 ...
------解决方案--------------------create table tb(ID varchar(10),DATE varchar(10),I1 varchar(10),I2 varchar(10),I3 varchar(10),I4 varchar(30),I5 varchar(30))
insert into tb values( 'A1 ', '02/06 ', '(857) ', ' ' , ' ' , ' ' , ' ')
insert into tb values( 'A1 ', '06/11 ', '(857) ', ' ' , ' ' , ' ' , ' ')
insert into tb values( 'A1 ', '08/02 ', '(855) ', '(857) ', ' ' , '(855,857) ', ' ')
insert into tb values( 'A1 ', '08/05 ', '(851) ', '(857) ', '(874) ',