The SQL having clause is used to limit the output of a conditional SQL statement. It is used by an SQL statement in the SELECT list of your columns.
You cannot specify an SQL standard for which SQL Aggregate functions are used for column terms in the SELECT list. For example, the following SQL statement produces an error:
SELECT Employee, SUM (Hours)
FROM EmployeeHours
Where sum (Hours)> 24
Group by Employee
The SQL statement of the HAVING clause is used for this purpose. To use the specified aggregation function, use the following conditions in your query:
SELECT Employee, SUM (Hours)
FROM EmployeeHours
Group by Employee
Having sum (Hours)> 24
The preceding SQL statement selects the total time of all employees and their respective time, as long as the number is 24 or more. The SQL HAVING Clause shows the following results:
Employee |
Hours |
John Smith |
25 |
Tina Crown |
27 |