from: http://zhidao.baidu.com/question/17022808.html?qbl=relate_question_1
where和having其实后面都是跟条件。区别在于:在他们后面的条件里如果有count之类的聚合函数的时候只能使用having而不能使用where。
这个是用在聚合函数的用法。当我们在用聚合函数的时候,一般都要用到GROUP BY 先进行分组,然后再进行聚合函数的运算。运算完后就要用到HAVING 的用法了,就是进行判断了,例如说判断聚合函数的值是否大于某一个值等等。 select customer_name,sum(balance) from balance group by customer_name having balance>200; 这个是银行数据库的例子