3

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?

Akina
  • 20,750
  • 2
  • 20
  • 22
Elikill58
  • 181
  • 3
  • 11

1 Answers1

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
Elikill58
  • 181
  • 3
  • 11