• Is the rt.productid referring to column that is part of the main query? I guess what I am asking is if your sub query is a correlated one. How about removing sub queries and replace them with derived tables?