I have a SQL command that uses lag to list the data in a table and calculate it with the previous value to calculate the percentage increase. On my localhost it works but on my host it keeps giving this error and I use mysql.
CREATE TABLE `results` ( `id` int(11) NOT NULL, `price` int(11) NOT NULL, `Date` date DEFAULT NULL, `grown` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
This is the command I use
SELECT *, - 100.0 * ( 1-price/ LAG(price) OVER (ORDER BY results.id)) AS Grown FROM results AS r ORDER BY r.id;