Difference between Where and Having clause


Where Clause Having Clause
WHERE clause can be used with
• SELECT
• INSERT
• UPDATE
• DELETE
Having clause can only be used with only SELECT
With other DDL commands you will get incorrect syntax error
WHERE clause is used for filtering rows and it applies on each and every row HAVING clause is used to filter groups in SQL.
WHERE clause can be used before or after GROUP BY clause HAVING clause is used after GROUP BY clause.
We can't use aggregate functions in the where clause unless it is in a sub query contained in a HAVING clause. We can use aggregate function in HAVING clause



2 comments:

  1. Thanks Learned a lot of new things from your post! Good creation and hats off to the creativity of your mind.
    Very interesting and useful blog! For more info:
    Manual Testing Training in Hyderabad

    ReplyDelete