You are viewing limited content. For full access, please sign in.

Question

Question

SQL Results With Duplicate Values

asked on April 29, 2014

I am doing a database query that returns a list of values such as this.

 

456489

456489

456489

425641

425641

123456

 

I would like the result that I put in a multi value field to be. 

 

456489

425641

123456

 

Is there a way to do this in a workflow preferably without a script but I am open to options.

 

Currently I am using a standard query option with a for each row with an assign values element inside the for each row.  

0 0

Answer

APPROVED ANSWER
replied on April 29, 2014

Thank you all for your responses.  

 

In my workflow when it all boiled down to it I clicked one check box, told it to remove duplicates and was done.  I was not familiar with this function and was amazed when I really grasped what it could do.  

 

I am perhaps blind in one eye but I had some trouble finding it so here is a shortcut for those of us hard of seeing.  Under the Token Dialog check Apply Function then choose the Remove Duplicates option...  Worked great.

 

4 0
replied on March 25, 2021 Show version history

Thank you - did not realize that function was there!  Just used it to filter out unique values for a specific template field within a folder, and to then perform an operation once per each unique value. 

0 0

Replies

replied on April 29, 2014

It looks like you're close! Creating a multi-value token with the list of values is the first step in my solution to this issue. I did this by using a 'For Each Row' activity to iterate through my query results and fill in a new multi-value token with the values from the desired column. Once we have a token with our results, we can assign it to the metadata field and use the "Remove Duplicates" token function to screen out the duplicates. Note that the "Remove Duplicates" token function is only available in Workflow 9.0.1 and later.

 

Here is the workflow described above, which is adding results from the "result" column in my database to the "Aliases" field:

4 0
replied on April 29, 2014 Show version history

Most likely the easiest solution will be to add a distinct clause to the original query. Your query will end up looking something like this:

 

SELECT DISTINCT col1
FROM table1

 

2 0
replied on April 29, 2014

If your database is SQL you can add Distinct to the select statement. This will only return distinct results to begin with. Then you can add the results directly into a multi-value token. I am sure all database engines support some similar method of returning distinct results.

 

For example SELECT DISTINCT Number from Numbers

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.