MSSQLWindow FunctionsFIRST_VALUE
LEAD

FIRST_VALUEWindow Functions

LAST_VALUE

Returns the first value in the window frame.

Syntax

FIRST_VALUE(expr) OVER (w)

Example

Enter values below to update the example in real time.

department_id
employee_id
salary
dept_max
employees
SELECT department_id, employee_id, salary,
       FIRST_VALUE(salary) OVER (PARTITION BY department_id ORDER BY salary DESC) AS dept_max
FROM employees;