InterviewPrepKit

Home / SQL / Query Basics

Select and Filter Employees

easy
Solving tips
  • Reach for a WHERE clause and combine conditions with AND when every condition must hold.
  • String comparisons are case-sensitive in standard SQL, so match the department value exactly.
  • Select only the columns the task asks for instead of using SELECT *.

You are given a table of company employees. Return the higher earners inside a single department so a hiring manager can review them.

Schema

CREATE TABLE employees (
  id         INTEGER PRIMARY KEY,
  name       TEXT NOT NULL,
  department TEXT,
  salary     INTEGER,
  hire_date  DATE
);

Sample data:

idnamedepartmentsalaryhire_date
1AliceEngineering950002019-03-01
2BobEngineering820002020-06-15
3CarolSales700002018-01-10
4DaveEngineering1100002017-09-23
5EveMarketing880002021-02-28
6FrankSales910002016-11-05

Task

Return the id, name, and salary of every employee in the Engineering department whose salary is greater than 85000. Order the rows by salary in descending order.

Expected output

idnamesalary
4Dave110000
1Alice95000
Your workspace Not runnable by design — this is your interview scratchpad. Saved on this device.