ควิซ SQL: Aggregates & NULL

Aggregate functions quietly skip NULL, which can change an average or turn a total into NULL. This SQL quiz tests those rules, the empty-result case and how COALESCE gives you the numbers you expect.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% SQLite

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 10

What does this query return?

CREATE TABLE scores (student TEXT, points INTEGER);
INSERT INTO scores VALUES ('Ana', 10), ('Ben', NULL), ('Cy', 20), ('Dee', NULL);
SELECT AVG(points) FROM scores;
ดูเฉลย

B. 15.0 AVG ignores NULLs, so it averages only 10 and 20: 30 / 2 = 15. SQLite prints it as 15.0. If the missing scores should count as 0, the answer would be 7.5.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • SUM, AVG, MIN and MAX ignore NULL
  • Why AVG(points) can differ from SUM(points) / COUNT(*)
  • SUM of no rows is NULL, COUNT of no rows is 0
  • Treating missing values as zero with COALESCE
  • How GROUP BY handles NULL keys

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง