Loading topic guide...
Relational databases provide ACID guarantees through Write-Ahead Logging (WAL) and B-Tree indexing structures.
-- Finding second-highest salary with Window Function
WITH RankedSalaries AS (
SELECT employee_id, salary,
DENSE_RANK() OVER (ORDER BY salary DESC) as rank
FROM employees
)
SELECT salary FROM RankedSalaries WHERE rank = 2;DENSE_RANK handles ties properly without skipping rank numbers.