Sunday, March 1, 2009

WHERE Vs HAVING clause in SQL statement

Listed below are some reasons on when to use WHERE or HAVING clause in SQL SELECT statement.
  • WHERE clause is used to exclude rows before the grouping of data
  • Aggregate functions cannot be used in the WHERE clause
  • HAVING clause is used to exclude one or more aggregated results after grouping data
  • HAVING clause conditions can have aggregate functions
  • WHERE and HAVING clauses can be used together in a SQL statement

No comments:

Post a Comment