8. SQL Statements : SELECT (interactive) : Select Statement Clauses : HAVING Clause
 
Share this page                  
HAVING Clause
The HAVING clause filters the results of the GROUP BY clause, in the same way the WHERE clause filters the results of the SELECT...FROM clauses. The HAVING clause uses the same restriction operators as the WHERE clause.
For example, to return orders for each part for each day in the past week:
SELECT odate, partno, count(*) FROM orders
GROUP BY odate, partno
HAVING odate >= (date('today') - '1 week');
Any columns or expressions contained in the HAVING clause must follow the same limitations described for the SELECT clause.