Fix for aggregation producing incorrect results in incorrect format

- Integer values now show up as integers
- COUNT is calculated correctly