# Delete duplicate in sql

**URL:** <https://forum.inductiveautomation.com/t/delete-duplicate-in-sql/54260>\
**Category:** Ignition\
**Created:** [December 17, 2021, 7:31pm UTC](https://forum.inductiveautomation.com/t/delete-duplicate-in-sql/54260 "2021-12-17T19:31:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [December 17, 2021, 7:31pm UTC](https://forum.inductiveautomation.com/t/delete-duplicate-in-sql/54260/1 "2021-12-17T19:31:05Z")

</div>

I can select my duplicates here:

```auto
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

update:  
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.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [December 17, 2021, 9:22pm UTC](https://forum.inductiveautomation.com/t/delete-duplicate-in-sql/54260/2 "2021-12-17T21:22:38Z")

</div>

Use the IN clause and your subquery.

Example, where ID IN …
