private int getAggregateByPrecision(final String colName, final byte precision) throws SQLException {
        int count;
        try (final Connection connection = sqlStatisticsDbConnProvider.getConnection()) {
            try (final PreparedStatement preparedStatement = connection.prepareStatement(
                    "select sum(coalesce(" + colName + ",0)) " +
                            "from " + SQLStatisticNames.SQL_STATISTIC_VALUE_TABLE_NAME + " " +
                            "where PRES = " + precision)) {
                try (final ResultSet resultSet = preparedStatement.executeQuery()) {
                    resultSet.next();
                    count = resultSet.getInt(1);
                }
            }
        }
        return count;
    }
Test loads data into stat val src, with stats aged so that there are
equal numbers falling into each precision. It then does runs the
aggregation process and checks the right data is in stat_val. Following
this it does further iterations of loading more data and running
aggregation to verify the new data is being merged in and the old data is
rolled up. It uses a future 'current time' to replicate aggregation
running against stats that have been in stat_val for a while.
stroom-app/src/test/java/stroom/statistics/impl/sql/TestSQLStatisticAggregationManager.java