With SQL, a Having clause is similar to a Where clause for rows of data that have been aggregated into a single row of output. The system evaluates Where clauses by looking at the individual table rows before they are grouped by the aggregate function, and then it evaluates Having clauses after applying the function. Therefore, if you want to check the value returned by the function, you must define Having criteria.

 

For example, suppose you need a list of the careers in which the minimum amount due for student fees is greater than $100. In this case, you first use the aggregate function to group the careers based on the amount due. Then, you use the Having clause to obtain the list of the careers in which the minimum amount due is greater than $100.

 

In this topic, you want to calculate the total amount of fees owed from all the service indicators that have been placed on a person's records. You want to display only the IDs whose sum is greater than $9.00. You will use Having criteria to do this.

 


Table of Contents