selectDistinct
The selectDistinct
method creates a new table containing all of the unique values for a set of key columns.
When the selectDistinct
method is used on multiple columns, it looks for distinct sets of values in the selected columns.
Syntax
table.selectDistinct()
table.selectDistinct(columns...)
Parameters
Parameter | Type | Description |
---|---|---|
columns | String... | Key columns from which distinct values will be selected. |
columns | Selectable... | Key columns from which distinct values will be selected. |
columns | Collection<? extends Selectable> | Key columns from which distinct values will be selected. |
Returns
A new table containing all of the unique values for a set of key columns.
Examples
source = newTable(
stringCol("A", "apple", "apple", "orange", "orange", "plum", "grape"),
intCol("B", 1, 1, 2, 2, 3, 3),
)
result = source.selectDistinct("A")
- source
- result
source = newTable(
stringCol("A", "apple", "apple", "orange", "orange", "plum", "grape"),
intCol("B", 1, 1, 2, 2, 3, 3),
)
result = source.selectDistinct("A", "B")
- source
- result