COUNT, SUM, AVG, MIN, MAX

SQL provides aggregate functions to perform calculations on data:

  • COUNT() – Counts the number of rows
  • SUM() – Adds up numeric values
  • AVG() – Calculates the average
  • MIN() and MAX() – Find the lowest or highest value
SELECT COUNT(*) FROM orders;
SELECT SUM(price) FROM products;
SELECT AVG(age) FROM users;
SELECT MIN(score), MAX(score) FROM tests;
← PrevNext →