BeginnerSQL · 25 min · 12 challenges

NULL Values: Beginner

A host in Lisbon publishes a new Airbnb listing on Monday. By Tuesday nobody has stayed there, so its rating holds nothing at all. Record that gap as 0 and the flat looks like the worst stay in the city. Record it as missing and each query on the column needs a rule for the hole, whether it filters the rows or counts and averages them.

NULL vs zero vs empty string

Daily Life
Interviews
Every cell in a table holds one of 2 things: a value, or a marker saying that no value was recorded. That marker is NULL. It is how a database writes "we don't know" or "this doesn't apply" inside a cell.
Zero and the empty string both look like nothing, yet both are values. 0 is a number that someone measured or typed. '' is a piece of text that happens to contain no characters. NULL marks the absence of any value, which is why a column of any type can hold it: an INTEGER column can, and so can a VARCHAR or BOOLEAN one.
Databases need that marker because the alternative is to invent a value. A made-up birth year or a made-up price looks exactly like a real one, and every report built on the column would treat it as a measurement.

One table, 3 kinds of nothing

A shop keeps a products table. stock is an INTEGER counting units on the shelf, and description is a VARCHAR that the seller types into a form.

product_idnamestockdescription
1Desk Lamp12'Brass, 40cm tall'
2Notebook0'A5, 80 pages'
3MugNULL''
4Backpack7NULL
What each cell says
  • Notebook, stock 0: someone counted the shelf and found none. Sold out is a fact you can act on.
  • Mug, stock NULL: no count was recorded. The shelf could hold 0 mugs or 500.
  • Mug, description '': the seller saved the form with the box blank. An answer exists, and it is zero characters long.
  • Backpack, description NULL: no description was ever saved for this product.

Why the difference changes answers

A sold-out product and an uncounted product call for different actions. One needs a reorder, the other needs someone to walk to the shelf. If the table stored 0 for both, the question "which products are sold out?" would return products nobody has counted. The query below asks that question, and a second tab asks which descriptions were saved blank.
stock = 0 matches the Notebook only. The Mug's stock is NULL, and a missing count is a different thing from a count of 0.
SELECT
product_id,
name,
stock
FROM products
WHERE stock = 0
Result
product_idnamestock
2Notebook0
1 row

Where NULLs come from

NULL enters a table for 4 common reasons, and each one is a different story about the same empty cell.
  • An optional field was skipped: a customer checked out without entering a phone number.
  • The value does not exist yet: an order placed today has no delivery date.
  • The question does not apply: a house has no apartment number.
  • The column is newer than the row: a loyalty_tier column added this year is NULL for every customer who signed up before it existed.
The cell looks identical in all 4 cases, so the meaning has to come from knowing how the column gets filled.
In the cellA value?Reads as
0Yes, a numberMeasured, and the amount is zero
''Yes, textSaved, with no characters in it
NULLNoNothing was recorded
TIP
A result grid can draw NULL as the word NULL or as a blank cell, and a blank cell might also be an empty string. Looking isn't enough to tell them apart. Run a filter such as description = '' and see whether the row comes back.

Deciding what to store is a modelling choice that someone makes for every column. Try it on a tip column in a food delivery app's orders table.

Multiple Choice

An orders table has a tip column. For which order is NULL the accurate thing to store?

The rest of this lesson keeps coming back to one test: was anything recorded? If something was, the cell holds a value, even when that value is 0 or ''. If nothing was, the cell is NULL, and SQL will refuse to say whether it equals anything at all.

Three-Valued Logic

Daily Life
Interviews

A comparison such as amount > 150 has had 2 possible results so far: TRUE or FALSE. NULL adds a third. Ask whether an unrecorded region equals 'US' and the truthful reply is "can't tell". SQL calls that result UNKNOWN, and a query shows it as NULL.

Logic with 3 possible results is called three-valued logic. It follows one idea all the way through: when an input is missing, the result is whatever can still be known for certain, and often that is nothing.

Seeing the third value

A comparison is an expression, so it can sit in a SELECT list where its result shows up as a column. This query asks every order whether its region is 'US'.
SELECT
order_id,
region,
region = 'US' AS is_us
FROM orders
Result
order_idregionis_us
ORD-001US1
ORD-002NULLNULL
ORD-003EU0
ORD-004NULLNULL
ORD-005US1
5 rows

ORD-001 and ORD-005 come back TRUE and ORD-003 comes back FALSE. ORD-002 and ORD-004 have no region recorded, so the comparison has nothing on its left side to check, and is_us is NULL for both. Guessing FALSE would be a claim about a region nobody recorded, so the engine reports that it cannot tell.

What WHERE does with each result
  • ▸TRUE: the row is kept.
  • ▸FALSE: the row is dropped.
  • ▸UNKNOWN: the row is dropped, exactly as if it were FALSE.
That third line is where NULL changes results. WHERE only lets a row through when its condition is TRUE, so a row whose condition can't be decided never appears in the output. HAVING applies the same rule to groups.

Opposite filters that lose rows

In a table with no NULLs, the filter region = 'US' and its opposite region != 'US' split the rows into 2 piles that add up to the whole. NULLs add a third pile that neither filter returns. Here is each comparison worked out row by row.

order_idregionregion = 'US'region != 'US'
ORD-001USTRUEFALSE
ORD-002NULLUNKNOWNUNKNOWN
ORD-003EUFALSETRUE
ORD-004NULLUNKNOWNUNKNOWN
ORD-005USTRUEFALSE
Keeps the 2 rows where the comparison is TRUE: ORD-001 and ORD-005.
SELECT
order_id,
region
FROM orders
WHERE region = 'US'
Result
order_idregion
ORD-001US
ORD-005US
2 rows
The first filter returns 2 orders and its opposite returns 1. That accounts for 3 of the 5 rows. Anyone who reports "2 US orders, so the other 3 are non-US" has assigned a region to 2 orders that never had one.

Even NULL = NULL is unknown

The natural next move is to ask for the missing regions directly with region = NULL. Play the query and watch what each row's comparison produces.

SELECT
*
FROM orders
WHERE region = NULL
orders5 rows
order_id
amount
region
ORD-001
100
US
ORD-002
200
NULL
ORD-003
150
EU
ORD-004
300
NULL
ORD-005
250
US
Preparing the animation
It returns 0 rows. For ORD-001 the question is whether 'US' equals a value nobody knows, and that is UNKNOWN. For ORD-002 the question is whether one unknown value equals another. 2 missing regions could be the same region or different ones, so that's UNKNOWN too. No row reaches TRUE, and the query raises no error to warn you.

Every comparison operator you know behaves this way. Test a NULL with < or > and you get UNKNOWN. != and IN give the same answer.

AND with an unknown side

AND returns TRUE only when both of its sides are TRUE. Three-valued logic adds one rule: a FALSE on either side still settles the answer as FALSE, because nothing the unknown side turns out to be could rescue it. Otherwise an UNKNOWN side leaves the whole condition UNKNOWN.
Left sideRight sideLeft AND rightRow kept?
TRUETRUETRUEYes
TRUEUNKNOWNUNKNOWNNo
FALSEUNKNOWNFALSENo
UNKNOWNUNKNOWNUNKNOWNNo

Take WHERE region = 'US' AND amount > 250 on ORD-004, which has amount 300 and no region. The amount test is TRUE and the region test is UNKNOWN, so the row lands on the second line of the table and is dropped, even though its amount passes.

TIP
When a filter returns fewer rows than you expected, check the filtered column for NULLs before you check anything else. Missing values are the usual reason that 2 opposite filters fail to add up to the table.
Multiple Choice

orders holds 5 rows of (order_id, amount, region): (ORD-001, 100, US), (ORD-002, 200, NULL), (ORD-003, 150, EU), (ORD-004, 300, NULL), (ORD-005, 250, US). Which orders does this query return?

SELECT
order_id
FROM orders
WHERE region != 'EU'
AND amount > 100
So comparisons can find values and can rule values out, but they can't find a gap. Asking for the rows where a value is missing takes a different kind of test, one that looks at whether the cell holds anything at all.

IS NULL and IS NOT NULL operators

Daily Life
Interviews

SQL has a dedicated test for a missing value. phone IS NULL asks one thing about a cell: was anything recorded here? Unlike a comparison, that question always has a definite answer, so IS NULL returns TRUE or FALSE and never UNKNOWN.

The keyword is IS, because = compares 2 values and a NULL cell has no value to compare.

A shop's customers table has 4 people in it, and the support team wants to know who can't be reached by phone. Play the query to see the test run on each row.

SELECT
customer_id,
name,
phone
FROM customers
WHERE phone IS NULL
customers4 rows
customer_id
name
phone
1
Ann
555-0101
2
Ben
NULL
3
Cara
555-0199
4
Dev
NULL
Preparing the animation

Ben and Dev come back. For Ann and Cara the test is FALSE, because a phone number is sitting in the cell. For Ben and Dev it is TRUE. Every row got a yes or a no, which is exactly what the = comparison couldn't deliver.

The opposite test

IS NOT NULL flips the answer: TRUE when the cell holds a value, FALSE when it does not. It's the filter for "only rows where this was recorded", such as the customers a courier can call.

SELECT
customer_id,
name,
phone
FROM customers
WHERE phone IS NOT NULL
Result
customer_idnamephone
1Ann555-0101
3Cara555-0199
2 rows

It returns Ann and Cara. 2 rows from IS NULL plus 2 rows from ISN'T NULL make all 4 customers. This pair always splits a table with nothing left over, because each row answers TRUE to exactly one of them. Compare that with = 'US' and != 'US' in the last section, which lost 2 of 5 orders between them.

3 tests on the same 3 cells

The table below runs 3 tests on 3 possible contents of a phone cell. The middle row is the one from the first section: an empty string is a value, so IS NULL doesn't catch it.

phone holdsphone = NULLphone IS NULLphone IS NOT NULL
'555-0101'UNKNOWNFALSETRUE
''UNKNOWNFALSETRUE
NULLUNKNOWNTRUEFALSE

Combining it with other conditions

IS NULL is a condition like any other, so AND can join it to the comparisons you already write. And because it never returns UNKNOWN, it adds no third value to the AND. The finance team wants large orders that still need a region filled in.
SELECT
order_id,
amount
FROM orders
WHERE region IS NULL
AND amount > 250
Result
order_idamount
ORD-004300
1 row
Only ORD-004 qualifies. ORD-002 also has no region, but its amount of 200 fails the second test, so the AND comes out FALSE.

Auditing a column before you trust it

IS NULL is most useful as a check you run before any analysis, to find out how much of a column is missing. Pair the test with COUNT(*) and the size of the gap comes back as one number.

SELECT
COUNT(*) AS orders_missing_region
FROM orders
WHERE region IS NULL
Result
orders_missing_region
2
1 row
2 of 5 orders have no region. That is 40% of the table, and it tells you that any filter on a named region can reach at most 3 of the 5 orders.

The same pair of tools settles the puzzle from the last section. To report every order that isn't confirmed as US, you need 2 filters. region != 'US' finds 1 order with a different region and region IS NULL finds the 2 with no region at all, so the answer is 3. Together with the 2 US orders, all 5 rows are accounted for.

✓Do
  • Write IS NULL to find rows where a value is missing.
  • Write ISN'T NULL to keep only rows where a value was recorded.
  • Count the NULLs in a column before filtering or grouping on it.
✗Don't
  • Write = NULL or != NULL. Both return 0 rows and raise no error.
  • Expect IS NULL to catch empty strings. '' is a value.
  • Assume a filter and its opposite cover every row of the table.
Now build the test yourself, first by choosing the right operator and then by assembling a full query.
Loading the challenge
A real filter rarely tests for NULL alone. WHERE carries the first condition, and each AND line after it adds one more. The NULL test sits on its own AND line exactly as a comparison would, and a row comes back only when every line is TRUE for it. Build the next query that way: one comparison, one NULL test, joined by AND.
Complete the SQL

> The warehouse team wants the order_id and amount of every order above 150 that has a region recorded. Arrange the tiles into that query. 2 tiles do not belong.

1
2
3
4
With IS NULL you can find the gaps, and with IS NOT NULL you can step around them. Filters choose which rows a query reads. The next question is what happens when the rows stay in and an aggregate has to count or add a column that has gaps in it.

COUNT(*) vs COUNT(column)

Daily Life
Interviews

You've used both COUNT(*) and COUNT(column). On a column with no gaps they return the same number, which hides the fact that they ask different questions. COUNT(*) counts rows. COUNT(column) counts the rows where that column holds a value, and it steps over every NULL.

Here are the shop's 5 orders again, this time with their discount column: the amount taken off by a coupon. 3 orders have a discount recorded and 2 have NULL. Play the query to watch both counts walk the same rows.

SELECT
COUNT(*) AS total_rows,
COUNT(discount) AS rows_with_discount
FROM orders
orders5 rows
order_id
amount
discount
ORD-001
100
10
ORD-002
200
NULL
ORD-003
150
15
ORD-004
300
NULL
ORD-005
250
25
Preparing the animation

total_rows is 5 and rows_with_discount is 3. Read the star in COUNT(*) as "the row itself". A row exists whether or not its cells are filled, so a row full of NULLs still counts as 1 and no NULL can ever make COUNT(*) smaller. COUNT(discount) looks at one cell per row and adds 1 only when that cell has something in it.

Which count answers which question

QuestionCount to useAnswer here
How many orders were placed?COUNT(*)5
How many orders have a discount recorded?COUNT(discount)3
How many orders have no discount recorded?COUNT(*) - COUNT(discount)2
Subtracting one count from the other, as the third row does, gives the number of NULLs in a column without writing a WHERE, so it can sit beside other aggregates in the same query.
SELECT
COUNT(*) AS total_rows,
COUNT(discount) AS rows_with_discount,
COUNT(*) - COUNT(discount) AS rows_missing_discount
FROM orders
Result
total_rowsrows_with_discountrows_missing_discount
532
1 row

The same rule inside every group

GROUP BY changes nothing about the rule. Each group gets its own COUNT(*) and its own COUNT(discount), and the second one skips the NULLs inside that group. The orders also carry a channel column saying whether they came from the web or the app.

SELECT
channel,
COUNT(*) AS orders_placed,
COUNT(discount) AS orders_with_discount
FROM orders
GROUP BY channel
Result
channelorders_placedorders_with_discount
app21
web32
2 rows
The web channel has 3 orders and 2 of them carry a discount. The app channel has 2 orders and 1 with a discount. Anyone reading only the discount column would conclude the shop took 3 orders in total, when it took 5.
The gap between the 2 columns is the number of orders with no discount recorded in that channel: 1 for web and 1 for app.

2 details that follow from the rule

  • COUNT(DISTINCT column) skips NULLs as well. A region column holding US, NULL, EU, NULL, US has 2 distinct values to count, so the answer is 2.
  • COUNT never returns NULL. When every cell in the column is NULL, COUNT(column) returns 0, and that 0 is a real measurement: zero rows had a value.

How this goes wrong at work

The classic mistake is writing COUNT(some_column) out of habit when the question was about rows. The query runs, the number looks plausible, and it's too low by exactly the number of NULLs in that column. A table of 2,000,000 signups with a 3% NULL rate in referral_code would be reported as 1,940,000 signups.

The reverse mistake happens too: using COUNT(*) to answer "how many customers gave us a phone number?" and counting the customers who gave none. Before typing either one, say the question aloud. If it is about rows, use the star. If it's about a recorded value, name the column.

TIP
COUNT(order_id) equals COUNT(*) only while order_id has no NULLs. When you mean rows, write COUNT(*): it says so, and it stays correct if the column gains a gap later.
Loading the challenge
One more prediction, this time mixing the count with the filter from the previous section.
Multiple Choice

customers has 4 rows, and phone is NULL in 2 of them. What does this query return?

SELECT
COUNT(*) AS matching_rows,
COUNT(phone) AS phones_counted
FROM customers
WHERE phone IS NULL
COUNT is the gentlest place to meet this behaviour, because a count of skipped rows is still a sensible number. The other aggregates skip NULLs in the same way, and for an average the skipped rows change what the number means.

Aggregates with NULLs

Daily Life
Interviews

SUM and AVG treat a NULL the way COUNT(column) does, and so do MIN and MAX: they read the cells that hold a value and pass over the rest. Nothing warns you and no 0 goes in its place, so the aggregate runs as if the rows with NULL were absent from the table.

Discounts on the 5 orders run 10, NULL, 15, NULL, 25. Before playing the query, work out what you expect the total and the average to be.
SELECT
SUM(discount) AS total_discount,
AVG(discount) AS avg_discount
FROM orders
orders5 rows
order_id
amount
discount
ORD-001
100
10
ORD-002
200
NULL
ORD-003
150
15
ORD-004
300
NULL
ORD-005
250
25
Preparing the animation
The total is 50: 10 plus 15 plus 25. That number is the same whether you picture the NULLs as skipped or as zeros. The average is where the 2 pictures split. AVG divides 50 by 3, the number of recorded discounts, and returns around 16.67. Dividing by all 5 orders would give 10.

2 averages, 2 different questions

✓AVG(discount) returns 16.67
  • Divides by 3, the orders with a discount recorded
  • Answers: when a discount is recorded, how big is it?
  • Says nothing about the 2 orders with NULL
✗SUM(discount) / COUNT(*) returns 10
  • Divides by 5, every order in the table
  • Answers: how much discount does the shop give per order?
  • Treats each NULL as a discount of 0
SELECT
AVG(discount) AS avg_when_recorded,
SUM(discount) / COUNT(*) AS avg_per_order
FROM orders
Result
avg_when_recordedavg_per_order
16.66666666666666810
1 row
Both numbers are correct arithmetic. Which one belongs in a report depends on what a NULL means in this column, the question from the first section. If NULL means the customer used no coupon, the discount was 0 in fact, and 10 is the honest per-order figure. If NULL means the coupon data failed to load for those orders, nobody knows their discounts, and 16.67 is the best estimate from the rows that survived.

MIN and MAX

MIN and MAX compare values to find an extreme, and a NULL can't be compared with anything. So they leave NULLs out of the contest. NULL is never the smallest value in a column and never the largest.
SELECT
MIN(discount) AS smallest_discount,
MAX(discount) AS largest_discount
FROM orders
Result
smallest_discountlargest_discount
1025
1 row
The smallest discount is 10 and the largest is 25. Read the 10 with care: it's the smallest discount that was recorded. If the 2 NULL orders had no coupon, the true minimum across all orders is 0, and MIN has no way to know that.

When every value is missing

Skipping NULLs raises a question: what does an aggregate return when it skips everything? This query keeps only ORD-002 and ORD-004, the 2 orders with no discount.
SELECT
COUNT(*) AS rows_kept,
COUNT(discount) AS discounts_found,
SUM(discount) AS discount_total
FROM orders
WHERE order_id IN ('ORD-002', 'ORD-004')
Result
rows_keptdiscounts_founddiscount_total
20NULL
1 row

rows_kept is 2 and discounts_found is 0, but discount_total is NULL. SUM had no values to add, so it reports that it has no total, which is different from a total of 0. AVG returns NULL here for the same reason, as do MIN and MAX. COUNT is the one aggregate that answers with a number when nothing is there.

This shows up whenever a filter or a group contains no recorded values. A report cell for a channel with no discounts will show NULL where you may have expected 0.
AggregateOn 10, NULL, 15, NULL, 25On NULL, NULL
COUNT(*)52
COUNT(discount)30
SUM(discount)50NULL
AVG(discount)16.67NULL
MIN(discount)10NULL
MAX(discount)25NULL

Shipping a number people can trust

An aggregate over a column with gaps is a statement about part of the table, and whoever reads your number needs to know how big that part is. Put COUNT(*) and COUNT(column) next to every SUM or AVG you report.

SELECT
channel,
COUNT(*) AS all_orders,
COUNT(discount) AS discounted_orders,
SUM(discount) AS total_discount,
AVG(discount) AS avg_discount
FROM orders
GROUP BY channel
Result
channelall_ordersdiscounted_orderstotal_discountavg_discount
app212525
web322512.5
2 rows
Both channels gave away 25 in discounts. The web average is 12.5 across 2 discounted orders out of 3, and the app average is 25 from a single discounted order out of 2. With the counts beside it, nobody will mistake that 25 for a pattern.
✓Do
  • Report COUNT(*) and COUNT(column) beside every SUM or AVG.
  • Find out what NULL means in a column before averaging it.
  • Use SUM(column) * 1.0 / COUNT(*) when NULL should count as 0; the 1.0 keeps the fraction.
✗Don't
  • Assume AVG divides by the number of rows in the table.
  • Expect SUM to return 0 when every value is NULL. It returns NULL.
  • Treat MIN as the smallest value across all rows when some are NULL.
Multiple Choice

A reviews table has 4 rows. Read from top to bottom, its rating column holds 5, NULL, 3, NULL. What does this query return?

SELECT
AVG(rating) AS avg_rating
FROM reviews
Every result in this lesson traces back to one decision SQL made: a missing value is never guessed. Comparisons with it are UNKNOWN, filters drop what they cannot confirm, and aggregates work with the values they have. Your job is to know how many rows that left out.
PUTTING IT ALL TOGETHER

> Back to the new listing in Lisbon. Suppose a listings table holds 1,000 listings for the city, and 150 of them are too new to have a rating, so rating is NULL in those rows. A product manager asks 3 questions: how many listings are there, what is the average rating, and how many listings are rated below 4.5?

The modelling choice comes first: storing NULL for an unrated listing keeps "no reviews yet" apart from "0 stars", which is a real and terrible score.
COUNT(*) returns 1,000 and COUNT(rating) returns 850. The 150 between them are the new listings, the same rows that WHERE rating IS NULL returns.
AVG(rating) averages the 850 rated listings. Had the gaps been stored as 0, the same average would be divided by 1,000 and come out 15% lower.
WHERE rating < 4.5 returns rated listings only. For a new listing the comparison is UNKNOWN, so it is missing from that result and from rating > 4.5 as well.
A trustworthy answer gives the average across the 850 rated listings and says that 1,000 listings exist in total.
KEY TAKEAWAYS
NULL marks a value that was never recorded. 0 is a value and so is '', which is why = 0 and = '' never match a NULL.
A comparison with NULL returns UNKNOWN, and WHERE keeps a row only when its condition is TRUE.
IS NULL and IS NOT NULL always return TRUE or FALSE, so together they cover every row of a table.
COUNT(*) counts rows and COUNT(column) counts recorded values. Their difference is the number of NULLs in the column.
SUM and AVG skip NULLs, as MIN and MAX do. AVG divides by the recorded values, and an input with no recorded values returns NULL.

NULL means a value is missing, and every comparison, count and average treats that gap by its own rule.

NULL: the billion dollar mistake

Category
SQL
Difficulty
beginner
Duration
25 minutes
Challenges
12 hands-on challenges

Topics covered: NULL vs zero vs empty string, Three-Valued Logic, IS NULL and IS NOT NULL operators, COUNT(*) vs COUNT(column), Aggregates with NULLs

Lesson Sections

  1. NULL vs zero vs empty string

    Every cell in a table holds one of 2 things: a value, or a marker saying that no value was recorded. That marker is NULL. It is how a database writes "we don't know" or "this doesn't apply" inside a cell. Zero and the empty string both look like nothing, yet both are values. 0 is a number that someone measured or typed. '' is a piece of text that happens to contain no characters. NULL marks the absence of any value, which is why a column of any type can hold it: an INTEGER column can, and so can

  2. Three-Valued Logic (concepts: Three-Valued Logic)

    Logic with 3 possible results is called three-valued logic. It follows one idea all the way through: when an input is missing, the result is whatever can still be known for certain, and often that is nothing. Seeing the third value A comparison is an expression, so it can sit in a SELECT list where its result shows up as a column. This query asks every order whether its region is 'US'. That third line is where NULL changes results. WHERE only lets a row through when its condition is TRUE, so a r

  3. IS NULL and IS NOT NULL operators (concepts: Null Handling)

    The keyword is IS, because = compares 2 values and a NULL cell has no value to compare. The opposite test 3 tests on the same 3 cells Combining it with other conditions IS NULL is a condition like any other, so AND can join it to the comparisons you already write. And because it never returns UNKNOWN, it adds no third value to the AND. The finance team wants large orders that still need a region filled in. Only ORD-004 qualifies. ORD-002 also has no region, but its amount of 200 fails the second

  4. COUNT(*) vs COUNT(column) (concepts: Counting)

    Which count answers which question Subtracting one count from the other, as the third row does, gives the number of NULLs in a column without writing a WHERE, so it can sit beside other aggregates in the same query. The same rule inside every group The web channel has 3 orders and 2 of them carry a discount. The app channel has 2 orders and 1 with a discount. Anyone reading only the discount column would conclude the shop took 3 orders in total, when it took 5. The gap between the 2 columns is t

  5. Aggregates with NULLs (concepts: Sums & Averages)

    Discounts on the 5 orders run 10, NULL, 15, NULL, 25. Before playing the query, work out what you expect the total and the average to be. The total is 50: 10 plus 15 plus 25. That number is the same whether you picture the NULLs as skipped or as zeros. The average is where the 2 pictures split. AVG divides 50 by 3, the number of recorded discounts, and returns around 16.67. Dividing by all 5 orders would give 10. 2 averages, 2 different questions Both numbers are correct arithmetic. Which one be