Function AVG
19. AVG and NULLs
Functions SUM, MAX, MIN


Excellent. An important thing you should know about AVG is that it ignores NULL values. Let's say you want to find AVG(price) and you have the following three price values:

  • price = 100
  • price = 300
  • price = NULL
    • Some people could think that NULL is counted as zero, so the average of these three values would be (100+300+0)/3, which is 400/3. That's not true.

      NULLs are not taken into account at all, so you'll get (100+300)/2 = 200 here.


Take a look at the three projects of Adriana Fuentes, translator with id 5. Two of them have a NULL number of words.

Find the average number of words for all the projects of this translator. What do you think the average will be?

Stuck? Here's a hint!

Use a WHERE clause to pick the id.


Code editor