I run Mariadb on a Raspberry Pi
mysql -V shows the version to be 10.11.11-MariaDB.
Node-red has node-red-node-mysql v 2.0.0.
There is a table socketevent containing socketid (primary key), and ontime (datetime).
Gemini gives this SQL, strongly asserting that the RANGE BETWEEN INTERVAL syntax (which I'm not familiar with) works for interval units in Mariadb from v10.2.2 onwards
SELECT
ontime,
MIN(ontime) OVER (ORDER BY ontime RANGE BETWEEN INTERVAL 2 WEEK PRECEDING AND CURRENT ROW) AS min_ontime_prev_2weeks
FROM socketevent
LIMIT 10;
It gives an error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INTERVAL 2 WEEK PRECEDING AND CURRENT ROW) AS min_ontime_prev_2weeks
FROM
...' at line 3
Can anyone with understanding of the node and mariadb shed any light on this?
Gemini has suggested checking a couple of settings but in the end we are both stumped.
A template to define and populate socketevent:
[{"id":"db1dcd7eb57f8ed2","type":"template","z":"1138ada3048009d3","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"CREATE TABLE socketevent (socketid INT(11) NOT NULL, ontime DATETIME NOT NULL, PRIMARY KEY (SOCKETID));\nINSERT INTO socketevent (socketid, ontime) VALUES (1, '2025-08-06 06:44:13'), \n(2, '2025-08-06 06:59:26'),\n(3, '2025-08-06 11:07:02'),\n(4, '2025-08-06 18:15:51'),\n(5, '2025-08-07 07:15:57');","output":"str","x":260,"y":140,"wires":[["543c129233adda81"]]}]