The Question
SQL
Nth Highest Distinct Value
Given a table representing entity attributes with potential duplicates (e.g., Salaries), design a robust PostgreSQL solution to retrieve the value at the Nth rank of the unique descending sorted list. The solution must handle the edge case where the total number of unique values is strictly less than N by returning a SQL NULL.
PostgreSQL
Scalar Subquery
OFFSET
LIMIT
DISTINCT
B-Tree Indexing
April 2, 2026