This is the official manual of Mariadb: Last_value ().
Original:https://mariadb.com/kb/en/last_value/
I submit it to MARIADB official manual:https://mariadb.com/kb/zh-cn/last_value/
Grammar
LAST_VALUE(expr,[expr,...])
Describe
LAST_VALUE()
Evaluates all expressions and returns the last value.
This is useful when you use @var:=expr to assign a value to a variable . For example, when you want to get data from updated/deleted rows, you don't need to do two queries on the table.
Starting with the Mariadb 10.2.2, last_function can be used as a window function for a Windows functions.
Example
CREATE TABLE T1 (a int, b int); INSERT into T1 VALUES(1,ten), (2,+); DELETE from t1 WHERE a=1 and last_value(@a:=a,@b:=b,1 ); SELECT @a,@b;+------+------+| @a | @b |+------+------+| 1 | 10 |+------+------+Example of a translator supplement DELETE from T1; INSERT into T1 VALUES(1,ten), (2,a), (1 ,(+); DELETE from t1 WHERE a=1 and last_value(@a:=a , @b:=b,1); SELECT *,@a,@b;+------+------+------+------+| A | B | @a | @b |+------+------+------+------+| 2 | 20 | 1 | 30 |+------+------+------+------+
Back to Linux series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.html
Back to Site Architecture series article outline: http://www.cnblogs.com/f-ck-need-u/p/7576137.html
Back to Database series article outline: http://www.cnblogs.com/f-ck-need-u/p/7586194.html
Reprint Please specify source: http://www.cnblogs.com/f-ck-need-u/p/8616146.html
Note: If you think this article is not bad please click on the lower right corner of the recommendation, your support can inspire the author more enthusiasm for writing, thank you very much!
Translation: Last_value () function (submitted to MARIADB official manual)