結果 : how to avoid nested loops in sql server