Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


Selecting Groups - the HAVING Clause


The HAVING clause restricts the selection of groups in the same way that a WHERE clause restricts the selection of rows. However, in contrast to the WHERE clause, a HAVING clause may use a set function on the left-hand side of a comparison.

The HAVING clause is most often used together with a GROUP BY clause, 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:

 CURRENCY_CODE
 
 AUD
8
 CHF
2
 DKK
3
 EUR
23
 IDR
2
 ...
...


Mimer
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
info@mimer.se
Mimer SQL Documentation TOC PREV NEXT INDEX