<?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>I need to create a query rule to get distinct values from a table. The rule does</title><link>https://community.appian.com/discussions/f/general/3360/i-need-to-create-a-query-rule-to-get-distinct-values-from-a-table-the-rule-does</link><description>I need to create a query rule to get distinct values from a table. The rule does not need any input params. How would I go about it. The query rule needs me to take inputs and I dont see a way of adding a distinct to the select.... OriginalPostID-120965</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: I need to create a query rule to get distinct values from a table. The rule does</title><link>https://community.appian.com/thread/11733?ContentTypeID=1</link><pubDate>Tue, 02 Sep 2014 23:55:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2917c98a-f250-4eea-9bb4-1bc5801ab1a8</guid><dc:creator>karls</dc:creator><description>Thanks a lot. I will try this and let you know.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I need to create a query rule to get distinct values from a table. The rule does</title><link>https://community.appian.com/thread/11732?ContentTypeID=1</link><pubDate>Tue, 02 Sep 2014 23:23:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c58f0834-6b73-478e-acb0-3975e37b498a</guid><dc:creator>Sahil Gupta</dc:creator><description>You cannot specify distinct in the query rule as there is no keyword &amp;quot;DISTINCT&amp;quot; in query rules. To get the unique values for specific columns, below are the steps on how you can do this. I will use an example from my enviroment using screenshots to explain.&lt;br /&gt;&lt;br /&gt;1) Get all the columns like you asked in your question. &lt;br /&gt;&lt;br /&gt;For example: let&amp;#39;s say we have a table called sessions with the columns: sid which is unique primary key, evaluator (we will get distinct evaluators) and scheduled time. See screenshot1.jpg for this example.&lt;br /&gt;Let&amp;#39;s say I have a query rule called getAllSessions() which doesn&amp;#39;t take any inputs and returns me all the sessions. See screenshot2.jpg for this.&lt;br /&gt;&lt;br /&gt;2) Get the spefic column you want to distinct values of using the dot notation. In this case, I will use the column evaluator. So I will get all the evaluatrs using: rule!getAllSessions().evaluator&lt;br /&gt;&lt;br /&gt;3) There are two ways to get distinct values:&lt;br /&gt;&lt;br /&gt;a. Use the Appian Common Object rule APN_distinct which you can get by importing Appian Common Objects. See link on how to set this up:&lt;br /&gt;&lt;a href="https://forum.appian.com/suite/help/7.6/Appian_Common_Objects_Application.html"&gt;forum.appian.com/.../Appian_Common_Objects_Application.html&lt;/a&gt;&lt;br /&gt;You can download the Appian Common Objects from here (Click on Appian Common Objects 7.5 Release 1 Rules and Constants link): &lt;a href="https://forum.appian.com/suite/tempo/records/type/software/item/iwBWsQdLlzKy55h8y8zLE8XpcdtAxIPkLhXfeKVYg8ho-qtmcwCxoOf4e0NCw/view/summary"&gt;forum.appian.com/.../summary&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;=rule!APN_distinct(rule!getAllSessions().trainer)&lt;br /&gt;&lt;br /&gt;This will give you all the unique evaluators. See screenshot3.jpg for this.&lt;br /&gt;&lt;br /&gt;b. Use union function to achieve the same effect. This is easier but not recommended because it might be performance intensive:&lt;br /&gt;&lt;br /&gt;=union(rule!getAllSessions().evaluator, rule!getAllSessions().evaluator)&lt;br /&gt;&lt;br /&gt;This will give you all the unique evaluators. See screenshot4.jpg for this.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot1.jpg"&gt;&lt;img src="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot1.jpg" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot2.jpg"&gt;&lt;img src="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot2.jpg" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot3.JPG"&gt;&lt;img src="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot3.JPG" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot4.JPG"&gt;&lt;img src="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/screenshot4.JPG" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>