How can we retrieve the lowest salary across the entire department frame?
LAST_VALUE() with frame ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING captures the final row in the partition.
Full-window extremes, comparing against lowest tier in a partition, range spreads.
SELECT
department_id,
name,
salary,
LAST_VALUE(salary) OVER (
PARTITION BY department_id
ORDER BY salary
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS lowest_salary
FROM employees;Practice typing production-grade SQL code for Last Value.