Collections:
FIRST_VALUE() - First Value of Result Set Window
How to obtain the first value of a field expression in the current result set window using the FIRST_VALUE() function?
✍: FYIcenter.com
FIRST_VALUE(exp) is a MySQL built-in window function that
returns the first 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, FIRST_VALUE(name) OVER w FROM mysql.help_topic WINDOW w AS (PARTITION BY help_category_id); -- +-----+-----+----------------+--------------------------+ -- | tip | cid | name | FIRST_VALUE(name) OVER w | -- +-----+-----+----------------+--------------------------+ -- | 0 | 1 | HELP_DATE | HELP_DATE | -- | 1 | 1 | HELP_VERSION | HELP_DATE | -- | 2 | 2 | AUTO_INCREMENT | AUTO_INCREMENT | -- | 6 | 2 | BIT | AUTO_INCREMENT | -- | 7 | 2 | TINYINT | AUTO_INCREMENT | -- | 8 | 2 | BOOLEAN | AUTO_INCREMENT | -- | 9 | 2 | SMALLINT | AUTO_INCREMENT | -- ... -- +-----+-----+----------------+--------------------------+
Reference information of the FIRST_VALUE() function:
FIRST_VALUE(exp): val Returns the first 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 first value of exp in the current window. Available since MySQL 8.
Related MySQL functions:
⇒ LAG() - N-Row before Current Row within Window
⇐ DENSE_RANK() - Density Rank of Sorted Values
2024-09-28, 1431🔥, 0💬
Popular Posts:
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How to download Microsoft SQL Server 2005 Express Edition in SQL Server? Microsoft SQL Server 2005 E...
How to download and install Microsoft .NET Framework Version 2.0 in SQL Server? .NET Framework Versi...