How to merge duplicated results from a plural relevance

(imported topic written by mingjie91)

Hi.

I have a relevance statement which returns a plural result. Is there any way to merge the duplicated values in the result, like ``select distinct’’ in SQL?

Q: …

A: 10

A: 10

A: 20

I want to have a result as:

Q: …

A: 10

A: 20

Thanks,

Mingjie.

(imported comment written by BenKus)

q: unique values of (“10”;“10”;“20”)
A: 10
A: 20

Ben

(imported comment written by jessewk)

Hi Mingjie. Welcome to the forum!

(imported comment written by mingjie91)

Ben.

Thanks for your response.

I have another question: does ``unique values of’’ support tuple?

q: ((10, 1); (10, 1); (20, 1))

A: 10, 1

A: 10, 1

A: 20, 1

But,

q: unique values of ((10, 1); (10, 1); (20, 1))

E: The operator “unique values” is not defined.

Jesse, thanks. :slight_smile:

Thanks,

Mingjie.

(imported comment written by jessewk)

No, it only works on basic types.

You can do this though:

Q: unique values of (it as string) of ((10, 1); (10, 1); (20, 1))

A: 10, 1

A: 20, 1

Also note that unique values have an additional property ‘multiplicity’ that will tell you how many instances there are of that value:

Q: (it, multiplicity of it) of unique values of (it as string) of ((10, 1); (10, 1); (20, 1))

A: ( 10, 1 ), 2

A: ( 20, 1 ), 1

(imported comment written by mingjie91)

Great! It’s what I wanted to have. Thanks.

Mingjie.