src/EntityQueryBuilder.php
public function addGroupBy($groupBy)
    {
        /** @var array $groupFields */
        $groupFields = func_get_args();

        foreach ($groupFields as $group) {
            parent::addGroupBy($this->alias($group));
        }

        return $this;
    }
public function addGroupBy($groupBy)
    {
        /** @var array $groupFields */
        $groupFields = func_get_args();

        foreach ($groupFields as $group) {
            parent::addGroupBy($this->alias($group));
        }

        return $this;
    }
Adds a grouping expression to the query.

<code>
$qb = $em->createQueryBuilder()
->select('u')
->from('User', 'u')
->groupBy('u.lastLogin')
->addGroupBy('u.createdAt');
</code>

@param string $groupBy The grouping expression.

@return $this This QueryBuilder instance.
@throws \ReflectionException