Use desktop for interactive SQL sandbox

Welcome to SQLBook [>_]

Your personal SQL playground—connect, query, and master databases on your terms.

SQLBook lets you practice SQL against your own MySQL, PostgreSQL, MariaDB, or Oracle instances. No sample databases, no artificial constraints—just real queries on real data.


Your challenge

Given this table

DROP TABLE IF EXISTS employees;
CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  salary DECIMAL(10,2)
);
INSERT INTO employees VALUES
(1, 'Alice', 95000),
(2, 'Bob', 87000),
(3, 'Carol', 95000),
(4, 'Dave', 73000),
(5, 'Eve', 81000);


Find the second highest salary from employees table without using LIMIT or OFFSET.

Head over to SQL Editor to try it out.


Spoiler!!!

Solution is available here

SQL Output

SQL Challenge - The Second Highest Salary
Private
The Second Highest Salary, window functions
jrz1977
PostgreSQL
Created Dec 25, 2025
Updated Dec 26, 2025
1Notes Notes
2SQL SQL
3Tab-3 SQL
2 SQL 1 Notes
Switch to a SQL tab and press Alt+Enter to run queries
SQL Challenge - The Second Highest Salary Updated 12/26/25, 4:23 AM
Notes SQL Tab-3
Alt+Enter to run