Easy SELECT basics Employees database

Filter rows with WHERE

Question

Show the name and salary of employees who earn more than 7000.

employeesid, name, salary, department_id, manager_id, hired_on
departmentsid, name, city

Your query

Ctrl+Enter to run

Result

Press Run to see your query's result, or Check answer to compare it with the expected result.

Expected result

namesalary
Tom Becker8800
Priya Nair9200
Mei Chen7600
Hana Kim7300

Rows can come in any order. Column names do not have to match.

Hint

WHERE keeps only the rows where the condition is true.

Show the solution
solution.sql Run this code
SELECT name, salary
FROM employees
WHERE salary > 7000;

Why it works

WHERE is checked for every row before anything is returned. Only the four employees with a salary above 7000 pass the test.

Common mistake

"More than 7000" means > 7000. Using >= 7000 would also include someone who earns exactly 7000.

Want to try the query on MySQL or PostgreSQL? Open it in the SQL Online Compiler or SQLite Online.