What is the difference between the WHERE and HAVING clauses in SQL?

  • WHERE is used for filtering rows after grouping, and HAVING is used for filtering rows before grouping.
  • WHERE is used for filtering rows before grouping, and HAVING is used for filtering grouped rows after aggregation.
  • WHERE is used for joining tables, and HAVING is used for grouping rows.
  • WHERE is used for sorting rows, and HAVING is used for filtering rows.
The WHERE clause filters rows before any grouping or aggregation occurs, while the HAVING clause filters rows after the grouping and aggregation, making it suitable for conditions involving aggregated values.
Add your answer
Loading...

Leave a comment

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