How to Calculate the Mean, Median, and Mode in Oracle

Calculating the mean, median, and mode in Oracle SQL is a task often performed by report developers or anyone else working with SQL. Learn how to calculate these three values from a range of data in this article.

What is the Mean, Median, and Mode, and Standard Deviation?

Mean, median, and mode are three kinds of average values that can be obtained from a set of data.

You might have learnt about them in high school maths (like I did) but may have forgotten what they are (like I did).

Mean: This is the “average” that you might know. It’s the sum of all of the numbers divided by the count of numbers.

Median: This is the middle value of a list of numbers.

Mode: This is the value that occurs most often

Standard Deviation: A value that represents how much numbers differ from each other

Get Your Free PDF: 9 Ways to Improve your Database Skills

How Can I Calculate the Mean in Oracle SQL?

Let’s say we had a table of data called movie_ratings that looked like this:

It seems Oracle chooses a value that would be the middle point if there is an even number of values. New York shows 500 because the values are 100,500,500 and the middle value is 500. The same thing happens for Texas which shows 100,150,800 and has a median of 150.
Hope that makes sense!