Having Clause Examples

Example 1

Select c.name, sum(c.income) AS "Total Income"
  From customers c
Group By c.name
Having sum(c.income) > 50000 ;

Example 2

Select c.name, sum(c.income) AS "Total Income"
  From customers c
Where c.type = 'CORPORATE'
Group By c.name
Having sum(c.income) < 50000 OR sum(c.income) > 60000 ;


Example 3

Select name, avg(income)
 From customers
Group By name
Having sum(income) <
  (Select max(income)
     From customers
Group By name