1.

Differentiate between WHERE clause and HAVING clause in SQL.

Answer»

The following table lists the differences between the WHERE CLAUSE and the HAVING clause:

WHEREHAVING
The WHERE Clause is used to filter records from a table depending on a condition that is given.The HAVING Clause is used to filter records from groups based on a condition that is given.
You can use the WHERE Clause without the GROUP BY Clause.The HAVING Clause is ineffective without the GROUP BY Clause.
The WHERE Clause is used in ROW operations.The HAVING Clause is used to implement column operations.
The WHERE clause can be used in conjunction with the SELECT, UPDATE, and DELETE statements.Only the SELECT statement can EMPLOY the HAVING Clause.
The aggregate function cannot be used in the WHERE Clause.The HAVING Clause is capable of containing aggregate functions.
With single-row functions such as UPPER, LOWER, and so on, the WHERE Clause is used.With multiple-row functions like SUM, COUNT, and others, the HAVING Clause is employed.
The WHERE Clause comes before the GROUP BY Clause.After the GROUP BY Clause, the HAVING Clause is used.


Discussion

No Comment Found