Oracle эквивалент Postgres 'DISTINCT ON?

В postgres вы можете запросить первое значение в группе сDISTINCT ON. How can this be achieved in Oracle?

Из руководства postgres:

SELECT DISTINCT ON ( expression [, ...] ) keeps only the first row of each set of rows where the given expressions evaluate to equal. The DISTINCT ON expressions are interpreted using the same rules as for ORDER BY (see above). Note that the "first row" of each set is unpredictable unless ORDER BY is used to ensure that the desired row appears first.

Например, для данной таблицы:

<code> col1 | col2 
------+------
 A    | AB
 A    | AD
 A    | BC
 B    | AN
 B    | BA
 C    | AC
 C    | CC
</code>

Сортировка по возрастанию:

<code>> select distinct on(col1) col1, col2 from tmp order by col1, col2 asc;
 col1 | col2 
------+------
 A    | AB
 B    | AN
 C    | AC
</code>

Сортировка по убыванию:

<code>> select distinct on(col1) col1, col2 from tmp order by col1, col2 desc;
 col1 | col2 
------+------
 A    | BC
 B    | BA
 C    | CC
</code>

Ответы на вопрос(2)

Ваш ответ на вопрос