Solved

Is there a weighted average function in Oracle

Posted on 2004-04-23
2
4,792 Views
Last Modified: 2012-05-04
Is there a function that calculated a weighted average? I was browsing my Oracle Docs and I can't seem to find that type of function?
0
Comment
Question by:Marek_Zyskowski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:tarar1
ID: 10901582
Yes you are you are true...i think there is no such thing ...you will have to do that yourself

If you can tell us the requirments then may be we can help you
0
 
LVL 8

Accepted Solution

by:
baonguyen1 earned 125 total points
ID: 10901661
This is not mine but I found it from Oracle web site. Not sure if it can help you:
------------------------------
Away to calculate weighted averages is as follows:

Create a calculated item using the following formula:

Weighted avg = sum(Weighting Factor * Weighting item) / sum(Weighting Factor)
e.g.
Average Price = sum(Quantity * Price) / sum(Quantity)

Use this calculated item in your report instead of the original item.
When a row shows the lowest level of data the calculation equals to the original value, but the subtotals and the totals show the weighted values all across your report.

Please be aware of the fact that when you calculate weighted averages
your dataset may contain zero or null values for the values to weight.
In some cases you may want to eliminate these figures.

The formula might look as follows then:
Average Price =
sum( Decode( nvl(price),0,0, quantity * price ))
/
sum( Decode( nvl(price),0,0, quantity ))
----------------------
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question