For Oracle support & training call (800) 766-1884
Free Oracle Tips

Home
Oracle Tips
Oracle Code Depot
Oracle Monitoring
Oracle Consulting
Oracle Training
Oracle News
Oracle Forum
Oracle Support





 

Free Oracle Tips

image

 
HTML Text

Free Oracle App Server Tips

image

 
HTML Text


Privacy Policy

Redneck

Dress Code

Oracle tuning

Oracle training

Oracle support

Remote Oracle


 

   
  Oracle Tips by Burleson

Oracle 10g Ranking Functions

A ranking function typically compares the ranks of records in the data set, based on the values of a set of measures.

The default sorting of the ORDER BY in rank() is ASC (ascending), so the keyword 'asc' can be omitted in either the query or the materialized view.  Oracle 10g will do a general rewrite if the materialized view has the keyword and the query does not (and vice versa).

There are other situations where the materialized view is grouped on more columns than the query. Then, it may be possible to do a rollup and rewrite the query.

Let us look at an example where we have the materialized view rank_on_sum_mv, which groups data by prod_id and cust_id.

CREATE MATERIALIZED VIEW rank_on_sum_mv
ENABLE QUERY REWRITE AS
SELECT prod_id, cust_id, SUM(quantity_sold) AS
Total FROM sales GROUP BY prod_id, cust_id;

Here is a possible query rewrite statement:

SELECT prod_id, SUM(total),
RANK() OVER (ORDER BY SUM(total)) AS n_rank
FROM rank_on_sum_mv GROUP BY prod_id;


Get the complete Oracle10g story:

The above text is an excerpt from "Oracle Database 10g New Features: Oracle10g Reference for Advanced Tuning and Administration", by Rampant TechPress.  Written by top Oracle experts, this book has a complete online code deport with ready to use scripts. 

To get the code instantly, click here:

http://rampant-books.com/book_2003_2_oracle10g.htm


Need an Oracle Mentor?

BEI is now offering personal mentors for Oracle DBAs where you can have an Oracle expert right at your fingertips, anytime day or night. We work with hundreds of Oracle databases every year, so we know exactly how to quickly assist you with any Oracle question.

Why risk an unplanned outage? You can now get telephone access to Don Burleson or any of his Oracle Certified DBAs with more than 20 years of full-time IT experience. Click here for details:

http://www.dba-oracle.com/service_oracle_backup.htm

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Fast-Track Oracle Support
PO Box 511
Kittrell, NC 27544


Email BC: