<?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>using DISCTINCT on a query entity COUNT function</title><link>https://community.appian.com/discussions/f/data/10155/using-disctinct-on-a-query-entity-count-function</link><description>I created a view and need to dynamically do some aggregations. For example, I have below piece of SQL code: 
 SELECT COUNT (DISTINCT ENTITY_ID) COUNT_ROWS, A.PRODUCT FROM P360_V_RCT_COUNT A GROUP BY A.PRODUCT 
 Notice the DISTINCT on the COUNT function</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: using DISCTINCT on a query entity COUNT function</title><link>https://community.appian.com/thread/44860?ContentTypeID=1</link><pubDate>Fri, 14 Apr 2017 14:55:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cccfc015-3231-44fa-815a-a39b9a29a7ea</guid><dc:creator>aloks0189</dc:creator><description>&lt;a href="/members/erickp"&gt;erickp&lt;/a&gt; DISTINCT statement is used to return only distinct (different) values, we can consider without duplicate rows, so as you have mention above, you have created a view.&lt;br /&gt;
&lt;br /&gt;
When i talk in SQL Query side then, i can find that, you have used DISTINCT but i think it&amp;amp;#x27;s not in proper structure, you can try as below:&lt;br /&gt;
&lt;br /&gt;
SELECT DISTINCT COUNT(yourColumn) as COUNT_ROWS, A.PRODUCT as product&lt;br /&gt;
FROM P360_V_RCT_COUNT A&lt;br /&gt;
GROUP BY A.PRODUCT&lt;br /&gt;
&lt;br /&gt;
So here i kept DISTINCT just after the Select, so once this view starts to return the DISTINCT column then we can create a normal queryEntity which can do our Job.&lt;br /&gt;
&lt;br /&gt;
Coming to your requirement: &lt;br /&gt;
I think for your requirement View is the right choice instead of doing it through QueryEntity, because i don&amp;amp;#x27;t think we have any DISTINCT function support in Appian. Because as per the Appian Documentation: aggregationFunction (Text): The function to use when aggregating the field. Valid values include COUNT, SUM, AVG, MIN, and MAX.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>