Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Counting and averaging · ⁨การนับและการหาค่าเฉลี่ย⁩

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

ไทย

สรุปผลด้วยฟังก์ชันรวม

บางครั้งคุณไม่ต้องการตัวแถวเอง แต่ต้องการ สรุป ของมัน ฟังก์ชันรวม เปลี่ยนหลายแถวให้เป็นค่าเดียว:

  • COUNT(*) — จำนวนแถว
  • SUM(col) — ผลรวม
  • AVG(col) — ค่าเฉลี่ย
  • MIN(col) / MAX(col) — ค่าต่ำสุด / สูงสุด
SELECT COUNT(*) FROM student;

COUNT, SUM และ AVG ลดคอลัมน์ทั้งหมดเหลือตัวเลขเพียงตัว

Handout · ⁨เอกสารประกอบการเรียน⁩

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP