Introduction This post shows how to use Common Table Expressions (CTE ) in WHERE CLAUSE of a query. Purpose We have hierarchy of a category up to nth level and we have to apply any action i.e. update/delete for entire hierarchy. For this we use CTE query to get entire hierarchy but we can’t use