الانتقال إلى المحتوى
English
Summarising with aggregate functions

Sometimes you do not want the rows themselves, but a summary of them. Aggregate functions turn many rows into a single value:

  • COUNT(*) — how many rows
  • SUM(col) — the total
  • AVG(col) — the average
  • MIN(col) / MAX(col) — the smallest / largest
SELECT COUNT(*) FROM student;

A price column 3, 8, 12, 20: COUNT(*) is 4, SUM(price) is 43, AVG(price) is 10.75

ورقة عمل

تسجيل الدخول أو إنشاء حساب

IGCSE, A-Level & AP