Break up query for better performance in SQL Server