mysql> select * from FinalTable;
+------+-------+-------+---------------------+
| id | name | state | timestamp |
+------+-------+-------+---------------------+
| 12 | name1 | TX | 2020-01-25 11:29:36 |
| 14 | name3 | CA | 2020-01-25 11:29:36 |
| 14 | name3 | TX | 2020-01-25 11:29:36 |
| 12 | name1 | CA | 2020-01-25 11:29:36 |
| 13 | name2 | TA | 2020-01-25 11:29:36 |
| 14 | name3 | CA | 2020-01-25 11:29:36 |
+------+-------+-------+---------------------+
Я смотрю на выходной запрос, который выдает ответ:
I2 name1 TX 2020-01-25 11:29:36 CA 2020-01-25 11:29:36
, когда я запускаю запрос,
select id,name,state,timestamp,
lead(state,1) over (partition by id order by timestamp asc) out_state,
lead(timestamp,1) over (partition by id order by timestamp asc) out_timestamp
from FinalTable
ERROR 1064 (42000): 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 '(partition by id order by timestamp asc) out_state,
lead(timestamp,1) over (part' at line 2
также возможно создать метку времени до миллисекунд а не секунды в БД? Я использую CURRENT_TIMESTAMP.