๐โโ๏ธ ๐ ๐ฒ: Just tweak the offset:
SELECT DISTINCT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 2;
๐ง Logic Breakdown:
-
OFFSET 2 skips the top 2 salaries -
LIMIT 1 fetches the 3rd highest -
DISTINCT ensures no duplicates interfereโ Use Case: Top 3 performers, tiered bonus calculations
๐ก Pro Tip: For ties, use
DENSE_RANK() or ROW_NUMBER() in a subquery.๐ฌ Tap โค๏ธ for more!