Select top 2 highest salaries using LIMIT.
Ready — edit the code above and click Run.
-- MySQL schema
CREATE TABLE employees (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), dept_id INT, salary DECIMAL(10,2));
CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO employees (name, dept_id, salary) VALUES ('Ali',1,90000),('Sara',2,120000);
INSERT INTO departments VALUES (1,'Engineering'),(2,'Sales');
SELECT name, salary FROM employees ORDER BY salary DESC LIMIT 2;
Try solving on your own first, then reveal the official answer.
MySQL uses LIMIT for pagination—PostgreSQL uses LIMIT too; SQL Server uses TOP.