Delete duplicate in sql

I can select my duplicates here:

select * from 
SELECT *, duprank= ROW_NUMBER() OVER (
              PARTITION BY line,code order by (select null))
from mytable) subq
where duprank>1 

How do I delete them though?
I keep getting error by select

I somehow got it to work, but I have no idea how.
When I tried selecting again, the duplicates were gone haha
But I didn’t see what worked

update 2:
I am running version 8.1.0
I think if I run delete from…
I get a no set shows up, but the delete happens.

Not sure if that was supposed to only work in updatequery, but I thought so.

Use the IN clause and your subquery.

Example, where ID IN …

1 Like