COUNT, AVG and SUM
COUNT(*) counts rows, COUNT(column) counts rows where that column is not NULL, SUM adds values and AVG gives the mean. ROUND keeps the result tidy.
Example
SELECT COUNT(*) AS students, COUNT(score) AS with_score
FROM students;Result
students | with_score 8 | 7
Example
SELECT SUM(price) AS total_price, ROUND(AVG(price), 1) AS average_price
FROM courses;Result
total_price | average_price 40000 | 8000.0
Exercise
Count all rows.
SELECT (*) FROM students;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.