2

I'm trying to run this query:

SELECT uuid, 
       brainffa - LAG(brainffa, 1) OVER (ORDER BY brainffa) as brainffa 
FROM time_played 
WHERE automatic = 1 AND name LIKE 'all%' 
ORDER BY uuid DESC LIMIT 15

This query works fine with MySQL, but on this another db server, on MariaDB (version: 10.6.5-MariaDB-1:10.6.5+maria~bionic) it failed with this error:

#4016 - Window function is not allowed in window specification

I searched in PhPMyAdmin for an option to allow window function, but I didn't find.

How can I allow it?

1
  • 2
    I think this might be because of the way MariaDB treats column aliases; try assigning an alias that's different from the actual column name.
    – mustaccio
    Aug 31 at 11:36

1 Answer 1

2

As Mustaccio said, the error comes from alias.

By using as brainffa_result, it works. Now, it's fine with MariaDB and MySQL.

My final SQL query:

SELECT uuid, 
       brainffa - LAG(brainffa, 1) OVER (ORDER BY brainffa) as brainffa_result
FROM time_played 
WHERE automatic = 1 AND name LIKE 'all%' 
ORDER BY uuid DESC LIMIT 15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.