Eng 6485 fix bug of limit and group by

Same bad change. Revert it back.