3188
MariaDBERRORNotableWindow FunctionsHIGH confidence
Illegal ORDER BY in window function
Production Risk
Low — parse-time error.
Why it happens
- 1Using an ORDER BY expression inside a window function that does not support it.
- 2ORDER BY not permitted for aggregate window functions without OVER.
How to reproduce
trigger — this will error
trigger — this will error
SELECT SUM(val ORDER BY id) OVER () FROM t1;
expected output
ERROR 3188 (HY000): Illegal ORDER BY in window function.
Fix
Move ORDER BY to the OVER clause
Move ORDER BY to the OVER clause
SELECT SUM(val) OVER (ORDER BY id) FROM t1;
Why this works
Window function ordering goes inside OVER(), not inside the function call.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3188 ER_WINDOW_ILLEGAL_ORDER_BY
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev