I am trying to run a simple SELECT command that includes LAG on goormIDE and keep getting an error message. I have a table with 2 columns: date, amount, and I am trying to retrieve a list of the amounts and next to each amount the amount from the previous row as opening_balance. Here's the code I use:
SELECT date, amount, LAG(amount, 1) OVER () opening_balance FROM transactions;
The error message I get is:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() opening_balance FROM transactions' at line 1".
Can anyone help a newbee with this?
SELECT date, amount, LAG(amount, 1) OVER () opening_balance FROM transactions;
The error message I get is:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() opening_balance FROM transactions' at line 1".
Can anyone help a newbee with this?