DP-600 · 2.2.9 · Prepare data
Filter data
Filter data
Use WHERE for rows, HAVING for aggregate groups, and for window results, placing each filter at the earliest valid stage.
The core idea

Place a filter at the earliest stage where its condition exists. WHERE handles row-level , HAVING handles aggregate results, and handles window-function output.
cannot be referenced in WHERE because they have not been calculated yet.
A comparison with is unknown, so expressions such as Region <> 'West' also exclude NULL unless you add an explicit IS NULL branch.
Key points
- WHERE: filters individual rows before grouping
- HAVING: filters groups after aggregates are calculated
- : filters rows after
- : keep or remove explicitly with IS NULL checks
Click an underlined term for a one-line explanation, or see them all in the glossary .
Exam trap
Putting a such as ROW_NUMBER in WHERE fails. Move the condition to , or compute the number in a CTE first.
Sources · 4 Microsoft Learn pages Show ▾
- SELECT - QUALIFY clause (Transact-SQL)
- NULL and UNKNOWN (Transact-SQL)
- Work with data in a Spark dataframe (Use Apache Spark in Microsoft Fabric)
- Filter by values in a column (Power Query)
Checked on October 4, 2026. Report a problem
Go deeper on Microsoft Learn
- SELECT - QUALIFY clause (Transact-SQL)
- NULL and UNKNOWN (Transact-SQL)
- Work with data in a Spark dataframe (Use Apache Spark in Microsoft Fabric)
- Filter by values in a column (Power Query)
Checked against Microsoft Learn on October 4, 2026. Report a problem with this card