• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5487
  • Last Modified:

Is there a weighted average function in Oracle

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?
1 Solution
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
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)
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 ))

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now