WHAT IS THE DIFFERENCE BETWEEN A "WHERE" CLAUSE AND A "HAVING" CLAUSE?

Pushpendra Singh

Total Post:241

Points:1205
Posted by  Pushpendra Singh
 1240  View(s)
Ratings:
Rate this:
  1. Amit Singh

    Post:565

    Points:2825
    What is the difference between a "where" clause and a "having" clause?

    Difference between a Where Clause and a Having Clause

    Having Clause is basically used only with the GROUP BY function in a query.
    WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

    Syntax
    Having Clause:

    SELECT column_name, aggregate_function(column_name)
    FROM table_name
    WHERE column_name operator value
    GROUP BY column_name
    HAVING aggregate_function(column_name) operator value

    Where Clause

    SELECT column_name(s)
    FROM table_name
    WHERE column_name operator value


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!