3264
MySQLERRORNotableWindow FunctionsHIGH confidence

PARTITION BY cannot be used in a window reference

Production Risk

Low — query is rejected; restructure the WINDOW definition.

How to reproduce
trigger — this will error
trigger — this will error
SELECT ROW_NUMBER() OVER (w PARTITION BY dept) FROM t1 WINDOW w AS (ORDER BY salary);

expected output

ERROR 3264 (HY000): Cannot override PARTITION BY of window 'w'.

Fix

Move PARTITION BY to window definition

Move PARTITION BY to window definition
SELECT ROW_NUMBER() OVER (w) FROM t1 WINDOW w AS (PARTITION BY dept ORDER BY salary);

Why this works

Define PARTITION BY in the WINDOW clause instead of the OVER reference.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3264 ER_WINDOW_PARTITION_IN_LIST_PART

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors