MySQLWindow 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.

employee_id
department_id
salary
top_salary
employees
-- 부서 내 최고 연봉자 급여를 각 행에 표시
SELECT employee_id, department_id, salary,
       FIRST_VALUE(salary) OVER (PARTITION BY department_id ORDER BY salary DESC) AS top_salary
FROM employees;