By 25/02/2016 1 Comments

What Is HAVING Clause In SQL?

  • SQL HAVING clause is used with multi-row functions.
  • SQL HAVING clause filters or restricts the result-sets returned by the multiple-row functions.
  • SQL WHERE clause does not restrict the result-sets returned by the multiple-row functions so SQL added a special clause¬†HAVING for that purpose.
  • SQL HAVING clause uses conditions for filter the result-sets¬†such as (<,>,==) etc.


SELECT column_name, multi-row-function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING multi-row-function(column_name) operator value;

Example: Use HAVING clause with SUM() function

SELECT b.buyer_name, SUM(p.price) AS "Total price"
FROM buyers b
INNER JOIN products p
ON b.buyer_id = p.buyer_id
GROUP BY p.buyer_id
HAVING SUM(p.price) > 3000;
  • In above example the HAVING clause filters a result-set returned by SUM() function so only price which is greater than 3000 will be selected/displayed.

Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .