SQL/MP Query Guide
Retrieving Data: How to Write Queries
HP NonStop SQL/MP Query Guide—524488-003
1-6
Organizing Results
The DISTINCT Clause
The DISTINCT clause eliminates duplicate rows from the result table. Consider the
query in Example 1-2. Part numbers 212 and 244 appear several times in the result.
To eliminate the duplicate rows, you can add a DISTINCT clause, as shown in
Example 1-3.
When evaluating the DISTINCT clause, SQL considers all null values to be duplicates
and leaves a single null value.
The DISTINCT clause does not imply ordering; to request a specific order, use the
ORDER BY clause.
Example 1-2. SELECT Statement With Duplicate Rows
SELECT PARTNUM FROM ODETAIL ;
PARTNUM
-------
244
2001
.
.
244
5103
.
.
244
.
.
212
.
.
212
7301
--- 72 row(s) selected.
Example 1-3. SELECT Statement With DISTINCT Clause
SELECT DISTINCT PARTNUM FROM ODETAIL ;
PARTNUM
-------
244
.
212
.
.
7301
--- 27 row(s) selected.










