<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Duplicate entries in database table</title><link>https://community.appian.com/discussions/f/data/26916/duplicate-entries-in-database-table</link><description>Hi, 
 I have a situation where there is a need to identify the duplicate entries in a database table and delete the duplicate rows. How can I do this?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Duplicate entries in database table</title><link>https://community.appian.com/thread/105809?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2022 09:09:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:71a00b0c-219d-4dc9-b2f9-7b35a3fbfdb9</guid><dc:creator>Praful Singhal</dc:creator><description>&lt;p&gt;You can use this query in stored procedure which can be triggered from the process model.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate entries in database table</title><link>https://community.appian.com/thread/105798?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2022 04:23:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9f426266-e1b0-4d96-82ee-35307b406df7</guid><dc:creator>Anuradha C</dc:creator><description>&lt;p&gt;Hi Praful, thanks for ur reply. Where in Appian do i use this SQL query?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate entries in database table</title><link>https://community.appian.com/thread/105764?ContentTypeID=1</link><pubDate>Tue, 20 Dec 2022 13:35:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bf1125a3-092e-43c5-baa5-5153c90bd33f</guid><dc:creator>Praful Singhal</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="sql"&gt;DELETE 
    FROM
    employee
WHERE
    id IN(
    SELECT
        id
    FROM
        (
        SELECT
            id,
            RANK() OVER(
            PARTITION BY firstname,
            middlename,
            lastname
        ORDER BY
            id
        ) my_rank
    FROM
        employee) AS c
        WHERE
            c.my_rank &amp;gt; 1
    );&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;you can use this MySQL code to delete the duplicate row in my employee table I have 4 columns id(PrimaryKey),firstname,middlename,lastname. Above mention query will delete all the duplicate rows but will keep one entry of each unique row.&lt;/p&gt;
&lt;p&gt;Note this query can partition on the basis of one column or multiple columns or all the columns depending on your requirement change the table name and column names used in the partition. if you want to remove all the duplicates then no need to apply where clause c.my_rank&amp;gt;1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate entries in database table</title><link>https://community.appian.com/thread/105757?ContentTypeID=1</link><pubDate>Tue, 20 Dec 2022 05:06:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e3e8405c-8939-473f-ab2f-2a359bf4a601</guid><dc:creator>Eunnel</dc:creator><description>&lt;p&gt;&lt;span&gt;You can use GROUP BY and HAVING clause,&amp;nbsp;&lt;/span&gt;&lt;span&gt;or maybe do some data locking to prevent duplicates.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;a href="https://community.appian.com/w/the-appian-playbook/196/data-locking-strategies"&gt;community.appian.com/.../data-locking-strategies&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>