FIRST_VALUE
Purpose
For each row, this function returns the result of expr from the first row in the window.
Syntax
first_value::=
Usage Notes
- Due to the fact that Exasol distributes all rows across the cluster,
FIRST_VALUEis non-deterministic as an aggregate function. Accordingly,FIRST_VALUEserves primarily as a help function in the event where only the same elements are present in a group. FIRST_VALUEas aggregate function ignores theRESPECT NULLSoption.FIRST_VALUEis also non-deterministic as analytic function if theover_clausedoes not contain anorder_clause. For more information, refer to Analytic Functions section.
Example
Analytic Function
SELECT
id, department, hire_date,
FIRST_VALUE(id) OVER (PARTITION BY department ORDER BY hire_date) FIRST_
FROM employee_table ORDER BY department, hire_date;
Result
| ID | DEPARTMENT | HIRE_DATE | FIRST_ |
| 2005 | ACCOUNTS | 2013-01-01 | 2005 |
| 2003 | ACCOUNTS | 2015-07-01 | 2005 |
| 2002 | ACCOUNTS | 2017-01-01 | 2005 |
| 2004 | ACCOUNTS | 2017-01-01 | 2005 |
| 2001 | ACCOUNTS | 2018-07-01 | 2005 |
| 1003 | HR | 2014-01-01 | 1003 |
| 1002 | HR | 2016-01-01 | 1003 |
| 1004 | HR | 2016-01-01 | 1003 |
| 1001 | HR | 2018-01-01 | 1003 |