Reputation: 24077
So I have a table with fields ID
(AI, primary key), ticker
, priceDate
, price
.
I have a bunch or records that share the same priceDate
and ticker
. There should only be one record per ticker
for any given priceDate
.
How would I go about removing these duplicate records, given that priceDate
and ticker
are not unique fields?
Upvotes: 0
Views: 133
Reputation: 204746
delete from your_table
where id not in
(
select * from
(
select min(id)
from your_table
group by pricedate, ticker
) x
)
Upvotes: 1