sql cte vs temp table vs subquery