MS SQL bug. Aggregate functions applied to ordered query.