SQL Having

SQL Having

The SQL HAVING is typically used with a GROUP BY clause.
The HAVING is used to return records where aggregate values meet the specified conditions.

Having syntax

SELECT column_name1, column_name2, function(column_name1)
FROM table_name
GROUP BY column_name1, column_name2
HAVING function(column_name1) operator value

Having example

Coder books table

IDTitlePriceDescription
1Learn SQL20Learn SQL language
2Learn MySQL22Learn MySQL language
3HTML book17Learn HTML
4Learn PHP20Introduction to PHP
5Learn PHP20PHP course
SELECT price, count(price) p_count
FROM coder_books
GROUP BY price
HAVING count(*) > 0

Result

Pricep_count
171
203
221