Translation: Last_value () function (submitted to MARIADB official manual)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.