Solved

Is there a weighted average function in Oracle

Posted on 2004-04-23
2
4,468 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL query of Oracle 10g database. 8 73
Schema creation in Oracle12c 6 38
Export table into csv file in oracle 10 40
help on oracle query 5 30
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now