Documentation Index
Fetch the complete documentation index at: https://docs.oxla.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheFIRST_VALUE() is a window function that retrieves the first value in an ordered set of values within a specified partition.
Syntax
The syntax for this function is as follows:Parameters
expression: target column or expression that the function operates onPARTITION BY: optional clause, which divides the result set into partitions to which theFIRST_VALUE()function is applied (if omitted, the entire result set is treated as a single partition)ORDER BY: order of rows in each partition to which the function is appliedRANGE BETWEEN: range-based window frame relative to the current row
Example
For the needs of this section, we will use a simplified version of thefilm table from the Pagila database, containing only the title, length and rating columns. The complete schema for the film table can be found on the
Pagila database website.
FIRST_VALUE() function to retrieve the title of the film with the shortest duration, partitioning results by rating and ordering by length.