SQL Topic collection

WHERE Clause & Filtering SQL Topic exercises

Practice SQL WHERE clauses with realistic boundary, NULL, text, date, exclusion, and production-filtering problems.

Exercises
12
Difficulty
Beginner to Advanced

What this collection tests

Skills and query patterns

Comparison predicates, boolean logic, ranges, dates, NULL handling, text matching, exclusions, and sargable filters

Curated exercises

Choose an exercise

Work in the live editor where supported. Advanced guided labs state their engine boundary before you open the workspace.

  1. Exercise 1Easy

    Locate an Employee by First Name

    Find the employee whose first name is exactly John.

    • Filtering

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  2. Exercise 2Easy

    Audit Candidates Across Numeric Boundaries

    Find the approved audit slice for candidates 102 through 109: compensation above $60,000 and capped at $75,000.

    • Filtering

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  3. Exercise 3Easy

    Select Employees for Role Mapping

    Find employees assigned to either IT_PROG or HR_REP.

    • Filtering

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  4. Exercise 4Easy

    Find Employees by Name Prefix

    Find employees whose first name begins with J.

    • Filtering

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  5. Exercise 5Medium

    Apply One Salary Rule to Two Teams

    Find IT or Sales candidates who earn strictly more than $70,000.

    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  6. Exercise 6Medium

    Review Candidates at Inclusive Salary Boundaries

    Find candidates earning from $60,000 through $75,000.

    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  7. Exercise 7Medium

    Extract February Payment Events

    Find completed payment events that occurred during February 2025.

    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  8. Exercise 8Medium

    Audit Unusable Active Contact Numbers

    Find active contacts whose phone is NULL, empty, or whitespace-only.

    • String functions
    • NULL handling
    • Filtering

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  9. Exercise 9Hard

    Exclude Jobs Safely When Rules Contain NULL

    Find employees whose job code does not match any exclusion rule.

    • Subqueries
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  10. Exercise 10Medium

    Match Imported Names Across Letter Case

    Find every contact matching ALICE JOHNSON regardless of letter case.

    • String functions
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  11. Exercise 11Hard

    Rewrite a Date Filter for Index Use

    Find events that occurred on February 14, 2025.

    • Date analysis
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  12. Exercise 12Hard

    Build a Production Review Cohort

    Find eligible candidates who joined during 2023–2024 and have a usable contact status.

    • String functions
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
01

Attempt

Write a query or design from the brief before opening any hints.

02

Validate

Run it against the included dataset and inspect the output.

03

Explain

Compare the verified answer and explain each choice aloud.

Learn before practicing WHERE Clause & Filtering

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.