HAVING Clause

  • This is the least used clause.
  • It is a filter clause, like the WHERE clause,
  • and is only used after the GROUP BY has been done.

For example,

—GROUP BY CLAUSE

---GROUP BY CLAUSE

SELECT NAME, COUNT(*) AS Number_of_times
FROM col$
WHERE COL# = 1
GROUP BY NAME
HAVING COUNT(*) > 5;

 

USING THE HAVEING CLAUSE TO FIND DUPLICATES

SELECT EMPLOYEE_GOVERNMENT_ID, COUNT(EMPLOYEE_GOVERNMENT_ID) AS MYCOUNT
FROM TBL_EMPLOYEE
GROUP BY EMPLOYEE_GOVERNMENT_ID
HAVING COUNT(EMPLOYEE_GOVERNMENT_ID)> 1;

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top