MySQL Forums
Forum List  »  Newbie

LAG/LEAD function
Posted by: Amit Michaely
Date: November 27, 2018 02:51AM

Hello,
I tried to use LAG function to get the timestamp from the next row in my query.
This is my code -

SELECT id,device_id, time
LAG(time) OVER(W) AS 'lag', time - LAG(time) as 'lag diff'

FROM carlos.carlos_modem3gwatchdog
WINDOW W AS (ORDER BY time)

The error I got is -
Error Code: 1064. 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 '(time) OVER(W) AS 'lag', time - LAG(time) as 'lag diff' FROM carlos.carlos_mode' at line 2

I tried to do some changes (without window etc)
Every time I got this error.
Please if anyone knows how can I solve this problem I will appreciate it.
THX
Amit

Options: ReplyQuote


Subject
Written By
Posted
LAG/LEAD function
November 27, 2018 02:51AM
November 27, 2018 11:54AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.