COUNT, SUM, AVG, MIN, MAX
SQL provides aggregate functions to perform calculations on data:
COUNT()
– Counts the number of rowsSUM()
– Adds up numeric valuesAVG()
– Calculates the averageMIN()
andMAX()
– 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;