$u = new User(); $u->select_sum_related('invoice', 'total'); $u->group_by('id'); $u->having('total >', '100');