Use group aggregation for stats
Merge pull request #242 from LocalData/stats-group

Use group aggregation for stats