distinct
Syntax
distinct(X)
Arguments
X is a vector.
Details
Return the distinct elements from vector X. The order of the elements in the result is not guaranteed.
Examples
distinct 4 5 5 2 3;
// output
[3,2,5,4]
t=table(3 1 2 2 3 as x);
select distinct x from t;
distinct_x |
---|
2 |
1 |
3 |
select sort(distinct(x)) as x from t;
x |
---|
1 |
2 |
3 |
The function distinct
returns a vector, while the function set returns a set.
x=set(4 5 5 2 3);
x;
// output
set(3,2,5,4)
x.intersection(set(2 5));
// output
set(2,5)