Skip to main content
Version: Java (Groovy)

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

ParameterTypeDescription
columnsString...

Key columns from which distinct values will be selected.

columnsSelectable...

Key columns from which distinct values will be selected.

columnsCollection<? 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 = newTable(
stringCol("A", "apple", "apple", "orange", "orange", "plum", "grape"),
intCol("B", 1, 1, 2, 2, 3, 3),
)

result = source.selectDistinct("A", "B")