The difference between a "where" clause and a "having" clause is a "Where" clause is applied to enforce condition on select statement and a single row function and is applied prior to GROUP BY clause where as HAVING clause is applied to enforce condition of GROUP Function and is applied after GROUP BY clause in the inquiry.
When you are carrying out a summary query, you can also state a Having clause. This is similar to a Where clause, the only difference is it involves a summary value, in place of a column value.
The most basic way to understand the difference among a "Where" clause is a "Where" clause denotes the rows in your tables which have to be integrated in the summation. The "Having" clause operates after the summation has been carried out. It denotes which of the summary row are returned in your result-set
HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.
When you are carrying out a summary query, you can also state a Having clause. This is similar to a Where clause, the only difference is it involves a summary value, in place of a column value.
The most basic way to understand the difference among a "Where" clause is a "Where" clause denotes the rows in your tables which have to be integrated in the summation. The "Having" clause operates after the summation has been carried out. It denotes which of the summary row are returned in your result-set
Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.
Example of HAVING and WHERE in one query:
SELECT titles.pub_id, AVG(titles.price)
FROM titles INNER JOIN publishers
ON titles.pub_id = publishers.pub_id
WHERE publishers.state = 'CA'
GROUP BY titles.pub_id
HAVING AVG(titles.price) > 10