Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Function AVG
19. AVG and NULLs
Functions SUM, MAX, MIN
Review

Instruction

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.

Exercise

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. Name the column average. What do you think the average will be?

Stuck? Here's a hint!

Use a WHERE clause to pick the translator_id.