withDistinctOn

fun withDistinctOn(vararg columns: Column<*>): Query

Specifies that the SELECT query should retrieve distinct results based on the given list of columns.

This method can be used to set a DISTINCT ON clause for the query, which is supported by some SQL dialects (e.g., PostgreSQL, H2). The resulting query will retrieve rows that are distinct based on the specified columns.

Return

The current Query instance with the DISTINCT ON clause applied.

Parameters

columns

The columns to apply the DISTINCT ON clause.


fun withDistinctOn(vararg columns: Pair<Column<*>, SortOrder>): Query

Specifies that the SELECT query should retrieve distinct results based on the given list of columns with sort orders. This method sets a DISTINCT ON clause and may reorder the results as indicated.

This method can be used to set a DISTINCT ON clause for the query, which is supported by some SQL dialects (e.g., PostgreSQL, H2), along with an ORDER BY clause for the specified columns.

Return

The current Query instance with the DISTINCT ON clause and reordering applied.

Parameters

columns

The columns and their sort orders to apply the DISTINCT ON clause.