Easy SELECT basics Employees database

Select specific columns

Question

List the name and salary of every employee.

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
Ana Souza6500
Priya Nair9200
Lucas Moreau6800
Mei Chen7600
Omar Haddad5600
Sofia Rossi6100
Jonas Berg5400
Aisha Bello4700
Diego Ruiz4100
Hana Kim7300
Liam Walsh4300

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

Hint

Write the column names after SELECT, separated by commas.

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

Why it works

Listing columns after SELECT returns only those columns, in the order you write them. The rows are the same as with SELECT *, just narrower.

Common mistake

A missing comma (SELECT name salary) does not give an error. SQL reads it as "name, renamed to salary", so you get one column instead of two.

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