I need to create a query rule to get distinct values from a table. The rule does

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

OriginalPostID-120965

  Discussion posts and replies are publicly visible

  • You cannot specify distinct in the query rule as there is no keyword "DISTINCT" 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.

    1) Get all the columns like you asked in your question.

    For example: let'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.
    Let's say I have a query rule called getAllSessions() which doesn't take any inputs and returns me all the sessions. See screenshot2.jpg for this.

    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

    3) There are two ways to get distinct values:

    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:
    forum.appian.com/.../Appian_Common_Objects_Application.html
    You can download the Appian Common Objects from here (Click on Appian Common Objects 7.5 Release 1 Rules and Constants link): forum.appian.com/.../summary

    =rule!APN_distinct(rule!getAllSessions().trainer)

    This will give you all the unique evaluators. See screenshot3.jpg for this.

    b. Use union function to achieve the same effect. This is easier but not recommended because it might be performance intensive:

    =union(rule!getAllSessions().evaluator, rule!getAllSessions().evaluator)

    This will give you all the unique evaluators. See screenshot4.jpg for this.