可能重复:
SQL - 如何删除重复行?
我有一个结构如下的表:
create table MnA
(id int PRIMARY KEY IDENTITY not null,
symbol nvarchar(4) not null,
direction nvarchar(4) not null,
start_dt nvarchar(5) not null,
end_dt nvarchar(5) not null,
start_doy int not null,
end_doy int not null,
avg_price int not null,
min_price int not null,
max_price int not null,
avg_percent int not null,
min_percent int not null,
max_percent int not null,
history text not null,
percent_hit int not null,
aw_length int not null,
diff int not null,
date_change int not null)
我想删除有相似之处的行。
如果该行相同symbol, direction, start_doy
,diff
那么我想保留最高的那一行avg_percent
。
我将如何做到这一点?