HAVING

Specifies a search condition for a group or an aggregate.
[ HAVING search_condition ]

Arguments

search_condition
Specifies the search condition for the group or the aggregate to meet. When HAVING is used with GROUP BY ALL, the HAVING clause overrides ALL.
The HAVING clause works like the WHERE clause except that it is applied after the GROUP BY operation. This means that the HAVING clause can only make references to grouping aliases and aggregates, as illustrated in the following example.
select value c from Products as p 
group by p.CategoryId as c 
having c > 1000
select c from Products as p 
group by p.CategoryId as c, p.SupplierId 
having c > 1000
select value c from Products as p 
group by p.CategoryId as c 
having max(p.CategoryId) > 1000

Last edited Mar 9, 2013 at 7:55 AM by ansiboy, version 1

Comments

No comments yet.