This is easier to see:
declare @t table (Name varchar(100), Age int) insert @t values('A', 20),('B', 30),('C', 40),('D ', 25) ,(' A', 21),('A ', 32),(' A ', 28),('D ',10); select Name, Replace(Name,' ','-'), count(*) Count from @t group by Name
Note the space between A and the dot. He chose a 1-space version over 0-space.
Note also that the group D chooses the one that has 2 trailing spaces over 4.
So no, it does not perform RTRIM. However, this is a somewhat bland mistake, because it arbitrarily selected one of the two columns (the one that it came up with first) as a result of GROUP BY, which could throw you out if it made sense.
source share