AVG(amount) divides by the count of non-NULL amount values in each group.
highlighted = computed this step
Input table
Use the same sales rows so the average can be checked against the sum.
Group query
Group by category and average the non-NULL amounts.
GROUP BY category, AVG(amount)
Grouped output
Both averages are exact rational values because they are not whole numbers.
averages by category