Полезная информация

next up previous contents index
Next: Functions and Operators Up: Customizing Queries Previous: CASE Clause

Distinct Rows

It is often desirable to return the results of a query with no duplicates. The keyword DISTINCT prevents duplicates from being returned. Figure [*] shows the use of the DISTINCT keyword to prevent duplicate states and duplicate city and state combinations.

  
Figure: DISTINCT prevents duplicates
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...\vert~NJ
\par ~Williamsport~~~~\vert~PA
\par (5~rows)\end{list}\par
\end{figure}

Notice DISTINCT operates only on the columns selected in the query. It does not compare non-selected columns when determining uniqueness. Section [*] shows how counts can be generated for each of the distinct values.


Bruce Momjian
1999-11-21