Solved

Is there a weighted average function in Oracle

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle- set role and grant privileges 6 40
pivot rows to columns 1 35
sum of columns in a row in oracle 3 33
PL/SQl Expanding the WHERE statement in query 3 20
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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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 videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

827 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