Thursday, October 21, 2021

Where VS Having Clause in SQL

 Difference between Where and Having Clause?

It is one of the most popular SQL interview questions.

WHERE:- Where is used to filter the records in a table. It can be used with SELECT,INSERT and UPDATE clause.Aggregate functions like Sum,Min,Max,Count,Avg cannot be used with where clause if you do so, you will get an SYNTAX error.Where filter the rows before grouping clause.

HAVING:- Having clause is used to filter group records. It can only be used with the SELECT statement. Aggregate functions can be used with Having clause. Having filter the groups after the aggregation are performed.

No comments:

Post a Comment

"🚀 Delta Lake's Vectorized Delete: The Secret to 10x Faster Data Operations!"

"🚀 Delta Lake's Vectorized Delete: The Secret to 10x Faster Data Operations!" Big news for data engineers! Delta Lake 2.0+ in...