fg

fg

Posts

DISTINCT

Description:

The default display of queries is all rows, including duplicate rows.

To eliminate duplicate rows in the result, include the DISTINCT keyword in the SELECT clause immediately after the SELECT keyword. 

The DISTINCT clause can only be used with select statements; it cannot be used in INSERTUPDATE, or DELETE statements.

Examples: 

The default display 
 SELECT department_id
FROM   employees;

The select statement displays all the department numbers from the EMPLOYEES table. Note that the department numbers are repeated.

Suppress duplicates using DISTINCT.
SELECT DISTINCT department_id
FROM   employees;

The EMPLOYEES table actually contains 20 rows, but there are only seven unique department numbers in the table. 

No comments :

Post a Comment