Thursday, July 5, 2007

SQL Server @ WHERE vs HAVING Clause

WHERE vs HAVING Clause

Both are used to filter out the records but have coupe of differences:
  • HAVING can only be used with SELECT statement, while WHERE can be used for SELECT, UPDATE and DELETE.
  • HAVING specifies a search condition on group or aggregate function, while WHERE specifies the search condition on the individual rows.
  • HAVING is typically used with GROUP BY clause. If GROUP BY is not used then HAVING behaves like WHERE clause.

No comments: