> For the complete documentation index, see [llms.txt](https://mass-street-data-school.gitbook.io/deng100-workbook-example/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mass-street-data-school.gitbook.io/deng100-workbook-example/unit-2-introduction-to-sql-fundamentals/sql-language-basics/sample-code/filtering-data.md).

# Filtering Data

```sql
USE AdventureWorksDW2019MSDS

--Find full record count before you start
SELECT *
FROM dw.DimProduct
WHERE 1 = 1
AND IsMostRecentRecord = 1

SELECT ReorderPoint
FROM dw.DimProduct
WHERE 1 = 1
AND ReorderPoint >= 600
AND IsMostRecentRecord = 1

SELECT SafetyStockLevel
FROM dw.DimProduct
WHERE 1 = 1
AND SafetyStockLevel != 1000
AND IsMostRecentRecord = 1

SELECT *
FROM dw.DimDate
WHERE 1 = 1
AND [Date] BETWEEN '20050101' AND '20050107'

SELECT Size, Color
FROM dw.DimProduct
WHERE 1 = 1
AND Size IS NOT NULL
OR Color = 'Black'
AND IsMostRecentRecord = 1

SELECT ReorderPoint, ListPrice, Color, ListPrice
FROM dw.DimProduct
WHERE 1 = 1
AND (ReorderPoint > 350 AND ListPrice <> 0)
OR (Color = 'Black' AND ListPrice = 0)
AND IsMostRecentRecord = 1

SELECT ProductSubcategoryCK
FROM dw.DimProduct
WHERE 1 = 1
AND ProductSubcategoryCK IN (1, 6, 10, 15)
AND IsMostRecentRecord = 1

SELECT ProductAlternateKey, *
FROM dw.DimProduct
WHERE 1 = 1
AND ProductAlternateKey LIKE 'HN%'
AND IsMostRecentRecord = 1
```
