SUM adds a numeric column across matching rows; AVG is SUM divided by COUNT of non-null values. Both ignore NULLs entirely — which is usually what you want mathematically but occasionally surprises people expecting zeros to count. Round results explicitly (ROUND(AVG(salary), 2)) for clean reports.
--how it works
1
SUM totals a numeric column
SUM(salary) adds the values of every matching row — payroll in one number.
2
AVG is the mean
AVG(salary) = SUM ÷ COUNT over non-NULL values; NULLs are skipped, not zero-filled.
3
Combine them freely
One SELECT can output SUM, AVG, MIN, MAX, COUNT together.
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses →Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free →Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books →