Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL HAVING Clause      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: HAVING

Definition:
The Oracle PL/SQL HAVING clause is used to filter or restrict the groups formed by the GROUP_BY clause. It follows the GROUP_BY clause in the SELECT statement. The HAVING clause can also precede the GROUP_BY clause, but this isn't logical and is not recommended. All grouping is performed (and group functions executed) prior to evaluating the HAVING clause.

Difference between WHERE and HAVING
The WHERE clause will filter or limit rows as they are selected from the table, but before grouping is done. The HAVING clause will filter rows after the grouping.

Example Syntax:

SELECT <column list>, <group by function>
FROM <table name>
WHERE <conditions>
GROUP_BY <column list>
HAVING <group by function condition>


Example Usage:

SELECT JOB_ID, SUM(SALARY)
FROM EMPLOYEES
GROUP_BY JOB_ID
HAVING SUM(SALARY) > 10000


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 198 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?