1. There is no lag and lead function in MySQL because Oracle is used to it, and no such function is inconvenient. So I wonder if I can make it.
2. If the function is used, it can certainly be realized. But if you don't use a function, can it be implemented? After testing, it was found that the aim could be achieved.
For the LAG function, you can write this
Select @lagfield, @lagfiled: =targfield,t.* from Table T, (select @lagfield: = ") r
3, where Targfield is the field you want to render on the next line, depending on whether the field is a character or a number, the last select should be different,
1) If it is a number, it should (select @lagfield: =0) R,
2) If the character is in the example
4, for lead, just can opposite, can walk four steps
1) Generate RowNum
2) according to rownum reverse
3) According to the Lag way to achieve
4) in accordance with rownum positive sequence
The lag and lead functions of MySQL