Collections:
NTH_VALUE() - N-th Value of Result Set Window
How to obtain the n-th value of a field expression in the current result set window using the NTH_VALUE() function?
✍: FYIcenter.com
NTH_VALUE(exp, n) is a MySQL built-in window function that
returns the n-th 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, NTH_VALUE(name, 2) OVER w FROM mysql.help_topic WINDOW w AS (PARTITION BY help_category_id); -- +-----+-----+----------------+---------------------------+ -- | tip | cid | name | NTH_VALUE(name, 2) OVER w | -- +-----+-----+----------------+---------------------------+ -- | 0 | 1 | HELP_DATE | HELP_VERSION | -- | 1 | 1 | HELP_VERSION | HELP_VERSION | -- | 2 | 2 | AUTO_INCREMENT | BIT | -- | 6 | 2 | BIT | BIT | -- | 7 | 2 | TINYINT | BIT | -- | 8 | 2 | BOOLEAN | BIT | -- | 9 | 2 | SMALLINT | BIT | -- ... -- +-----+-----+----------------+---------------------------+
Reference information of the NTH_VALUE() function:
NTH_VALUE(exp, n): val Returns the n-th value of a field expression in the current result set window. Arguments, return value and availability: exp: Required. The field expression to be evaluated. n: Required. The position of row in the current window. val: Return value. The n-th value of exp in the current window. Available since MySQL 8.
Related MySQL functions:
⇒ NTILE() - Dividing Window into N Tiles
⇐ LEAD() - N-Row after Current Row within Window
2024-09-12, 1165🔥, 0💬
Popular Posts:
Can You Drop an Index Associated with a Unique or Primary Key Constraint in Oracle? You can not dele...
How to download and install Microsoft .NET Framework Version 2.0 in SQL Server? .NET Framework Versi...
How To View Data Files in the Current Database in Oracle? If you want to get a list of all tablespac...
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...