Filtering

SQL Filtering Interview Questions

Filtering is cutting a table down to the rows you actually want, with a WHERE clause in SQL or a boolean mask in pandas. Almost every interview question starts with it, and it is where people most often miss a condition hidden in the wording.

What filtering questions ask you to do

Across the questions here, these are the shapes that come up:

  • Return only the rows matching two or three conditions at once
  • Exclude a value from a column that can also be empty
  • Find rows inside a range where the boundaries matter
  • Match text while ignoring case or extra spaces
  • Find rows that have no matching record in another table

Common mistakes with filtering

Empty values are the usual culprit. In SQL an empty cell is NULL, and NULL fails every comparison you write, so filtering for a status that is not "canceled" silently drops every row where the status was never set at all. If a column can be empty, decide what should happen to those rows before writing the filter.

Questions to practice

Roles this comes up in

Companies these come from

Other topics