Filtering Data

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

Last updated