Having
Clause:
The HAVING clause enables you to specify conditions
that filter which group results appear in the final results.
The WHERE clause places conditions on the selected
columns, whereas the HAVING clause places conditions on groups created by the
GROUP BY clause.
Syntax:
The following is the position of the HAVING clause in a
query:
SELECT FROM WHERE GROUP BY
HAVING
ORDER BY
The HAVING clause must follow the GROUP BY clause in a
query and must also precedes the ORDER BY clause if used. The following is the
syntax of the SELECT statement, including the HAVING clause:
SELECT column1, column2
FROM table1, table2
WHERE [conditions]
GROUP BY column1, column2
HAVING [conditions]
ORDER BY column1, column2
Group
by Clause:
The SQL GROUP BY clause is used in collaboration with
the SELECT statement to arrange identical data into groups.
The GROUP BY clause follows the WHERE clause in a
SELECT statement and precedes the ORDER BY clause.
Syntax:
The basic syntax of GROUP BY clause is given below. The
GROUP BY clause must follow the conditions in the WHERE clause and must precede
the ORDER BY clause if one is used.
SELECT column1, column2
FROM table_name
WHERE [conditions]
GROUP BY column1, column2
ORDER BY column1, column2
No comments:
Post a Comment