Select (SQL): Difference between revisions

Content deleted Content added
Fjerdingen (talk | contribs)
Fjerdingen (talk | contribs)
Overview: remove the "syntactic sugar" part. DISTINCT makes full sense, (As in many cases you can achieve the same result in many ways. Here using UNION, GROUP BY and others.)
Line 56:
| quote = [...] the keyword DISTINCT [...] eliminates the duplicates from the result set.
}}
</ref>
</ref> Note that <code>DISTINCT</code> is an example of [[syntactic sugar]]: it is possible to achieve the same result by listing all selected columns (but not the aggregate functions, if any) in the <code>GROUP BY</code> clause.
 
The following example of a <code>SELECT</code> query returns a list of expensive books. The query retrieves all rows from the ''Book'' table in which the ''price'' column contains a value greater than 100.00. The result is sorted in ascending order by ''title''. The asterisk (*) in the ''select list'' indicates that all columns of the ''Book'' table should be included in the result set.