fix statistics query in postgres

when aggregate functions present, postgres requires all
non-aggregate columns selected to be included in group by clause
to ensure a single value is selected.

Change-Id: Iccbcd8046cca872e8eba472f48fa392114f34426
Closes-Bug: #1256318
Merge "fix statistics query in postgres"