Sql Remove Duplicates Using Window Function