[Solved] Using distinct for specific column in oracle


In your example the query returns distinct values for the combination of COLA and COLB.

Examine the syntax:
enter image description here

Note, that DISTINCT/UNIQUE/ALL can be only placed after SELECT and before of the first expression in the select list.

The documentation says that:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm

DISTINCT | UNIQUE

Specify DISTINCT or UNIQUE if you want the database to return only one
copy of each set of duplicate rows selected. These two keywords are
synonymous. Duplicate rows are those with matching values for each
expression in the select list.

ALL

Specify ALL if you want the database to return all rows selected,
including all copies of duplicates. The default is ALL.

The above means, that DISTINCT/UNIQUE is always applied to the whole select list, not to individual columns

solved Using distinct for specific column in oracle