Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+2
person also asked this
people also asked this
Replies
8 replies
Answers
1 answer
Subscribers
8 subscribers
Views
11274 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
achieving 'select DISTINCT'
paolos1
over 8 years ago
Hello everybody,
I have a CDT/Table 'assets' with the following structure:
idasset (primary,unique)
typeofasset : text
manufacturer : text
model : text
Now I would realize the following query (to be used in a form):
select distinct typeofasset from assets
But in documentation I did not find any connection to clause 'distinct', nor in query rules, neither in querySelection()
I have tried the following workaround (!!!) in file attached:
/* workaround to get unique values */
local!uniqueAssetsAvailables: union(
local!assetsAvailables.data.typeOfAsset,
local!assetsAvailables.data.typeOfAsset
),
Could someone please suggest a better solution? (we are using ver 7.1.0)
Thank you in advance for your help, best regards.
Paolo
OriginalPostID-265665
forum_distinct.txt
Discussion posts and replies are publicly visible
+2
Puspendu Pal
over 8 years ago
Hello Paolo,
Please refer the URL below :
docs.appian.com/.../Query_Recipes.html
. Look at the section - "Get the Distinct Values of a Field"
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 8 years ago
I was about to say - this definitely sounds like something queryAggregation might be able to handle.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mognons
A Score Level 2
over 8 years ago
Hi Paolo, you could also prepare an SQL view that implements your SELECT DISTINCT... statement, then map the view to a proper CDT and use Appian Query Rules (or a!queryEntity) to get the expected results.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
reginaldm377
over 8 years ago
Possibly an unnecessary question, but for clarification purposes, are you trying to return rows of data that contain only unique values in the Asset Type field, or are you simply wanting to return the name and count (for example) of unique asset types?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
reginaldm377
over 8 years ago
If its the latter, then what the others have posted will be the solution.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jasmins
over 8 years ago
Hi paolos , you can use rule!APN_distinct(local!assetsAvailables.data) directly ,it will return distinct elements from local!assetsAvailables.data array .
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumara0002
A Score Level 1
over 8 years ago
Hi Paolo, i would suggest to use executestored procedure(either smart service or function) if the volume of data is high. a!queryEntity() has limitation when the volume is high. Your workaround is correct.distinct was deprecated from 7.x versions of appian and union() is the workaround left.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Raj Yadla
over 8 years ago
Grouping using the queryAggregationColumn() also gives distinct values
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel