Eliminating duplicate rows

Result tables from SELECT statements can contain duplicate rows. You can use the DISTINCT keyword to eliminate the duplicates. For example, the following command returns many duplicate rows:

SELECT city, state FROM Employees

To list only unique combinations of city and state, use this command:

SELECT DISTINCT city, state FROM Employees

NoteThe ROLLUP and CUBE operators do not support the DISTINCT keyword.

This chapter provides an overview of single-table SELECT statements. For more information about single-table SELECT statements, see

Advanced uses of the SELECT statement are described in the next chapter.