Oracle Tutorial

What is Oracle
SQL Keywords

Oracle Wildcards

Oracle Wildcards

Oracle Aliases

Oracle Aliases

MySQL Tutorial

MySQL Tutorial

PL/SQL Tutorial

PL/SQL Tutorial

Oracle Interview Questions

Oracle Interview Questions and Answers


Oracle Select Distinct Statement

The Oracle SELECT DISTINCT statement is used to fetch unique record and remove duplicates from the result set. In Oracle, the DISTINCT clause doesn't ignore NULL values.

Note: When only one column is provided in the DISTINCT clause, the query will return the unique values for that column.
When more than one columns is provided in the DISTINCT clause, the query will retrieve unique combinations for the column listed.

Oracle SELECT Distinct Statement Syntax

To select the existing table, use the following syntax:

Syntax

SELECT DISTINCT Col1
FROM tablename 
[WHERE conditions];

Parameters:

tablename: The table name from which you want to fetch data.

conditions: The conditions optional parameter.

Oracle SELECT Distinct Statement examples

The following Oracle distinct statement to fetch unique records and remove duplicates from the result set:

Example

SELECT DISTINCT firstName FROM tblCustomerLoan;

Note:

In the above example, we are removing duplicates record for selected fields.

Oracle SELECT DISTINCT Statement examples With Multiple Fields

The following Oracle statement to select or fetch unique records and remove duplicates from the result set:

Example

SELECT DISTINCT firstName, lastName, address 
FROM tblCustomerLoan;

Note:

In the above example, we are fetching unique records in multiple fields.