Previous Topic: Retrieving Selected ColumnsNext Topic: Displaying Calculations in Columns


Eliminating Duplicate Data

Use DISTINCT

A table can have one or more columns with duplicate data entries. For example, the JOBLIST table lists COMPUTER OPERATOR three times because three employees have that title. To retrieve unique, rather than duplicate, values in a column, use the keyword DISTINCT in the SELECT statement.

Example

List unique job titles in the company:

select distinct title from joblist ! display

JOBLIST REPORT mm/dd/yy TITLE ──────────────────── ACCOUNTANT AP CLERK AR CLERK COMPUTER OPERATOR CUMULUS CARETAKER DATA ENTRY CLERK DATABASE ADMIN. DIR CORP CONFUSION DIR OPERATIONS DIR WEATHER DOCUMENTATION SPEC FINANCIAL ANALYST HUMIDITY CONTROL CLK ILLUSTRATOR - 1 -