ใช้ modifier WITH ROLLUP ร่วมกับ GROUP BY เพื่อเพิ่มแถวสรุประดับสูง (super-aggregate) ในผลลัพธ์
ตัวอย่าง
คิวรี่สรุปยอดรวมค่าใช้จ่ายต่อรายการ พร้อมแถวรวมทั้งหมด:
mysql> Select Item_name, SUM(Cost) AS Total_cost from Item_list GROUP BY Item_name WITH ROLLUP; +-----------+------------+ | Item_name | Total_cost | +-----------+------------+ | Notebook | 45.00 | | Pen | 31.70 | | Pencilbox | 125.20 | | NULL | 201.90 | +-----------+------------+ 4 rows in set (0.00 sec)
แถวสุดท้าย NULL แสดงยอดรวมทั้งหมด (Grand Total)