<?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>Find duplicate combinations in Database</title><link>https://community.appian.com/discussions/f/data/22648/find-duplicate-combinations-in-database</link><description>Hi Everyone, 
 Is there a way find out duplicate combinations in Appian DB Table and delete them. 
 For Example there is a table with columns Name and Place 
 
 
 
 NAME 
 PLACE 
 
 
 John 
 Newyork 
 
 
 Tom 
 Washington 
 
 
 John 
 Newyork 
 
 
 Robert</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Find duplicate combinations in Database</title><link>https://community.appian.com/thread/88562?ContentTypeID=1</link><pubDate>Thu, 02 Dec 2021 04:37:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ba8fd6bc-ef30-40f9-b1d3-bd37555c3e56</guid><dc:creator>TJ</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can also use the following database query to identify duplicate values.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;select name,&lt;br /&gt; place,&lt;br /&gt; count(name) as count&lt;br /&gt;From dbTable&lt;br /&gt;Group By name, place &lt;br /&gt;Order by count(name) desc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find duplicate combinations in Database</title><link>https://community.appian.com/thread/88546?ContentTypeID=1</link><pubDate>Wed, 01 Dec 2021 19:56:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e979bfbf-fbd7-412d-b74d-70de200212b2</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;First, I never recommend deleting any data unless there are legal obligations to do so - design patters should be configured to utilize something such as a &amp;quot;cancelled&amp;quot; flag which allows the data to retain but removes them from reporting/process data.&lt;/p&gt;
&lt;p&gt;However for related endeavors, I will typically create a view on the DB side which exposes a &amp;#39;total count&amp;#39; column for the fields in question, if this is a specific activity.&amp;nbsp; Alternatively, you will want to review &lt;a href="https://docs.appian.com/suite/help/21.4/fnc_system_a_queryaggregation.html"&gt;a!queryAggregation()&lt;/a&gt;.&amp;nbsp; This can help to return a list of distinct values across those fields, then you can query back to the DB over each set to determine the count of that combination and return the ids to use one for removal.&lt;/p&gt;
&lt;p&gt;What is the data set size like?&amp;nbsp; Manageable, or massive amounts of rows, etc?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!aggregationFields: {&amp;quot;requestByDivision&amp;quot;,&amp;quot;approval&amp;quot;},
  local!data: a!queryEntity(
    entity: cons!COE_DS_SAMPLE,
    query: a!query(
      paginginfo: a!pagingInfo(1,100),
      aggregation: a!queryAggregation(
        aggregationColumns: a!forEach(
          items: local!aggregationFields,
          expression: a!queryAggregationColumn(
            field: fv!item,
            isgrouping: true
          )
        )
      )
    )
  ),
  
  local!data.data
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>