Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Having Clause Jump to:  
Category: >> Oracle PL/SQL >> Having Clause Bookmark and Share

<< lastnext >>

Snippet Name: Having Clause

Description: Some example of using the 'HAVING' clause with 'GROUP BY'.

Also see:
» BETWEEN Condition
» LIKE Condition
» Combining the AND and OR Conditions
» OR Condition
» AND Condition
» Distinct
» WHERE Clause - Conditions
» EXISTS 2
» EXISTS
» WITH with CONNECT BY
» WITH Clause: Single alias
» WITH Clause: Double alias

Comment: (none)

Language:
Highlight Mode: PLSQL
Last Modified: March 01st, 2009

column owner format a10
column table_name format a32
column index_name format a32
column maxext format 99999
column numext format 99999
 
prompt CHECK Tables
SELECT 
   t.owner,
   t.table_name,
   MAX(t.max_extents) maxext,
   COUNT(extent_id) numext
FROM
   sys.dba_tables t,
   sys.dba_extents e
WHERE 
   t.table_name = e.segment_name AND
   t.owner = e.owner AND
   e.segment_type = 'TABLE'
GROUP BY 
   t.owner, 
   t.table_name
HAVING COUNT(extent_id)/ MAX(t.max_extents) > .8
/
 
prompt CHECK Indexes
SELECT 
   t.owner,
   t.index_name,
   MAX(t.max_extents) maxext,
   COUNT(extent_id) numext
FROM
   sys.dba_indexes t,
   sys.dba_extents e
WHERE 
   t.index_name = e.segment_name AND
   t.owner = e.owner AND
   e.segment_type = 'INDEX'
GROUP BY 
   t.owner, 
   t.index_name
HAVING COUNT(extent_id)/ MAX(t.max_extents) > .8
/
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 269 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?