SQL HAVING Clause: Main Tips
- The HAVING clause was added to SQL to add more functionality.
- WHERE keyword can not be used in union with other functions. That where HAVING clause come in handy.
- HAVING clause is often used with the COUNT function.
Syntax of SQL HAVING
SELECT name_of_column(s) FROM name_of_table WHERE condition GROUP BY name_of_column(s) HAVING condition ORDER BY name_of_column(s);
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid certificates of completion
- Professional service
- Flexible timetables
- A variety of features to choose from
- Professional certificates of completion
- University-level courses
- Multiple Online degree programs
- Great user experience
- Offers quality content
- Very transparent with their pricing
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
Let us say we have a database with information about pets.
Below is a "Pets" table:
SQL HAVING: Example
If we want to get the countries that have registered, for example, more than 2 pets, we would use HAVING clause.
The example below shows how to use it.
SELECT COUNT(ID), Country FROM Pets GROUP BY Country HAVING COUNT(ID) > 2;
Latest Udacity Coupon Found:
75% OFF COURSES
Udacity Black Friday Offer
The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!