รวมกลุ่มข้อมูล
ในแบบฝึกหัดสุดท้ายนี้ จะได้นำ GROUP BY มาใช้ร่วมกับฟังก์ชัน aggregate เช่น MIN ที่เรียนไปแล้วในบทนี้
เพื่อปิดท้ายบท เราจะกลับมาใช้ตาราง eurovision จากบทแรกอีกครั้ง
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
SQL Server เบื้องต้น
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
-- Retrieve the minimum and maximum place, and point values
SELECT
-- the lower the value the higher the place, so MIN = the highest placing
MIN(place) AS hi_place,
___(place) AS lo_place,
-- Retrieve the minimum and maximum points values. This time MIN = the lowest points value
___(points) AS min_points,
MAX(points) AS max_points
FROM
eurovision;