HAVING clause in SQL

Date Published: 23/08/2020 Published By: JaiSchool

HAVING clause is used to filter out records based on aggregated values. In the respect of aggregation, WHERE can't be used. It does not work.

Therefore, while applying condition where we are calculating fields data, we will use HAVING.

See below example-

SELECT SUM(price) AS year_sale FROM mobiles GROUP BY year HAVING year_sale < 50000;

Publish A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *