Popular Products from Microsoft BI Stack - Try Today!
- advertisement -

What is the Difference Between WHERE and HAVING Clauses in SQL Server

» July 3, 2010 | |

Qns by Labels

  • HAVING clause can be used only with a GROUP BY clause, where as a WHERE clause can be used with constructs like SELECT, UPDATE, DELETE etc.
  • HAVING clause is applied as a filter to the data / output resulting from the GROUP BY clause, where as a WHERE clause is applied to every row in the SELECT, UPDATE, DELETE etc constructs.
  • In queries where both HAVING and WHERE clauses are used, WHERE clause is applied first (to every row in the SELECT statement to filter the records before they are fed to GROUP BY clause for aggregation) and then the HAVING clause is applied (to filter the aggregated result from GROUP BY clause).
Bookmark and Share

2 comments:

Unknown August 8, 2016 at 11:51 PM  

Great Blog Thanks.

Here You Can Find Your First Round Intreview question For Job .

SSRS interview questions

Sgraph Infotech April 19, 2017 at 3:22 AM  

Thanks for sharing the best informative article....Am got the best information in this article..keep Sharing..

MSBI Demand

Post a Comment

Back to TOP