T-SQL task 9 - refactoring