class GroupBy {

    public void toSql(final StringBuilder builder) {
        builder.append(" GROUP BY ");
        for (final Pair<Func, Attribute> groupBy : _groupBys) {
            if (groupBy.first() != null) {
                String func = groupBy.first().toString();
                func = func.replaceFirst("@", groupBy.second().table + "." + groupBy.second().columnName);
                builder.append(func);
            } else {
                builder.append(groupBy.second().table + "." + groupBy.second().columnName);
            }

            builder.append(", ");
        }

        builder.delete(builder.length() - 2, builder.length());
        if (_having != null) {
            _having.toSql(builder);
        }
    }

    public  GroupBy(final J builder);

}