I have a query as below:
;With P As (Select CP.ProductID From CatProduct CP Join Product P On CP.ProductID = P.ProductID Join ProductType pt with(nolock)