When using the SELECT statement, you may not want duplicate information to be returned. For example, STAFF has a DEPT column in which several department numbers are listed more than once, and a JOB column in which several job descriptions are listed more than once.
To eliminate duplicate rows, use the DISTINCT option on the SELECT clause. For example, if you insert DISTINCT into the statement, each job within a department is listed only once:
SELECT DISTINCT DEPT, JOB FROM STAFF WHERE DEPT < 30 ORDER BY DEPT, JOB
This statement produces the following result:
DEPT JOB ------ ----- 10 Mgr 15 Clerk 15 Mgr 15 Sales 20 Clerk 20 Mgr 20 Sales
DISTINCT has eliminated all rows that contain duplicate data in the set of columns specified in the SELECT statement.