Group, sort and limit in statistics generator