rollup子句的语法错误

时间:2015-02-13 01:42:08

标签: mysql sql content-query-rollup

下面是我正在写的查询,但由于某种原因,它在“ROLLUP”一词之后给出了一个语法错误,小红色波浪线在'('汇总之后)。

SELECT building, room_number, time_slot_id, COUNT(*)
FROM class1
GROUP BY ROLLUP (building, room_number, time_slot_id)

1 个答案:

答案 0 :(得分:4)

您需要在With Rollup中使用group by。试试这个语法

SELECT building, room_number, time_slot_id, COUNT(*)
FROM class1
GROUP BY building, room_number, time_slot_id WITH ROLLUP 

了解更多信息check here