Collections:
LAST_VALUE() - Last Value of Result Set Window
How to obtain the last value of a field expression in the current result set window using the LAST_VALUE() function?
✍: FYIcenter.com
LAST_VALUE(exp) is a MySQL built-in window function that
returns the last value of a field expression
in the current result set window.
For example:
SELECT help_topic_id AS tip, help_category_id AS cid, name, LAST_VALUE(name) OVER w FROM mysql.help_topic WINDOW w AS (PARTITION BY help_category_id); -- +-----+-----+----------------+----------------------------+ -- | tip | cid | name | LAST_VALUE(name) OVER w | -- +-----+-----+----------------+----------------------------+ -- | 0 | 1 | HELP_DATE | HELP_VERSION | -- | 1 | 1 | HELP_VERSION | HELP_VERSION | -- | 2 | 2 | AUTO_INCREMENT | BLOB DATA TYPE | -- | 6 | 2 | BIT | BLOB DATA TYPE | -- | 7 | 2 | TINYINT | BLOB DATA TYPE | -- | 8 | 2 | BOOLEAN | BLOB DATA TYPE | -- | 9 | 2 | SMALLINT | BLOB DATA TYPE | -- ... -- +-----+-----+----------------+----------------------------+
Reference information of the LAST_VALUE() function:
LAST_VALUE(exp): val Returns the last value of a field expression in the current result set window. Arguments, return value and availability: exp: Required. The field expression to be evaluated. val: Return value. The last value of exp in the current window. Available since MySQL 8.
Related MySQL functions:
⇒ LEAD() - N-Row after Current Row within Window
⇐ LAG() - N-Row before Current Row within Window
2024-09-28, 1213🔥, 0💬
Popular Posts:
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time va...
Where to find MySQL database server tutorials? Here is a collection of tutorials, tips and FAQs for ...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Change the Name of a Database User in SQL Server? If you want to change the name of an existi...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...