CompTIA Tech+ (FC0-U71)Data and Database FundamentalsMedium

A technician needs to find only the employees who work in the Sales department from an Employees table. Which SQL query accomplishes this?

  1. ASELECT Department FROM Sales;
  2. BSELECT * FROM Employees ORDER BY Department;
  3. CSELECT * FROM Employees GROUP BY 'Sales';
  4. DSELECT * FROM Employees WHERE Department = 'Sales';
Show answer & explanation

Correct answer: D. SELECT * FROM Employees WHERE Department = 'Sales';

The WHERE clause filters records based on a condition, so WHERE Department = 'Sales' returns only rows matching that department. ORDER BY sorts results but doesn't filter, and GROUP BY aggregates rather than filters.

Why the other options are wrong

  • A. This incorrectly treats Sales as a table name rather than a value.
  • B. ORDER BY sorts all results but doesn't limit which rows are returned.
  • C. GROUP BY is used for aggregation, not filtering a specific value.

SQL WHERE Clause

The WHERE clause in SQL filters query results to only include rows that meet a specified condition.

  • Used with SELECT, UPDATE, DELETE statements
  • Filters based on column value conditions
  • Different from ORDER BY (sorting) and GROUP BY (aggregating)

Memory trick: WHERE = 'Where does this row belong?' filter

More Data and Database Fundamentals questions