|
|
Selecting Groups - the HAVING Clause
The
HAVINGclause restricts the selection of groups in the same way that aWHEREclause restricts the selection of rows. However, in contrast to theWHEREclause, aHAVINGclause may use a set function on the left-hand side of a comparison.The
HAVINGclause is most often used together with aGROUP BYclause, but may also be used to impose selection conditions on a column derived from a set function.Find the currency codes that are used by more than one country:
SELECT currency_code, COUNT(currency_code) FROM countries GROUP BY currency_code HAVING COUNT(currency_code) > 1;Returns:
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|