MySQL get the Nth highest salary using LIMIT OFFSET
SQL Dasun Kalupahana 79 views
SELECT DISTINCT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 1; -- change the offset for the 3rd, 4th, etc.
A classic interview question. DISTINCT skips ties, and OFFSET N-1 jumps to the Nth value. This example returns the 2nd highest.
Learn more on the blog
MySQL
PostgreSQL vs MySQL Performance: Real Benchmarks Compared
Last updated: 7 November 2026. See the update log at the end."Which...
8 min read
MySQL
MySQL Too Many Connections (Error 1040): Causes and Fixes
Your site suddenly shows a database error, and the log says this:ERROR...
5 min read
MySQL
Upgrade MySQL 8.0 to 8.4: What Breaks and How to Check
MySQL 8.0 reached end of life in April 2026, which means no...
7 min read