Question: Since mysql 5.7.5 group by have change

<https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html>

If I make this query

```
$qb = $this->createQueryBuilder('d');
$qb->select('ANY_VALUE(d.id), d.nom, count(d.nom) as lignes');
$qb->groupBy('d.nom');   
$qb->orderBy('d.nom');

```

I have a error

Expression #1 of `SELECT` list is not in `GROUP BY` clause and contains nonaggregated column '`sepultures.d0_.id`' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql\_mode=only\_full\_group\_by

As explain in mysql doc, this problem can resolve with any\_value like this

```
$qb = $this->createQueryBuilder('d');
$qb->select('ANY_VALUE(d.id), d.nom, count(d.nom) as lignes');
$qb->groupBy('d.nom');   
$qb->orderBy('d.nom');

```

But doctrine don't recognize this function

> 
> [2/2] QueryException: [Syntax Error] line 0, col 7: Error: Expected
>  known function, got 'ANY\_VALUE'
> 
> 
> 

How can I resolve it?

Answer: 
Very simple way:

1- Install this php lib : 

```
composer require beberlei/doctrineextensions

```

2- In doctrine.yaml add this extra config: 

```
doctrine:
    ...
    orm:
        ...
        dql:
            string_functions:
                MONTH: DoctrineExtensions\Query\Mysql\Month
                YEAR: DoctrineExtensions\Query\Mysql\Year
                DAY: DoctrineExtensions\Query\Mysql\Day
                ....................................

```

For more details, official docs is available here :
<https://packagist.org/packages/beberlei/doctrineextensions>
If doctrine does not recognise `any_value()` function, then you could execute the query as a raw sql statement:

```
$sql="select ANY_VALUE(d.id), d.nom, count(d.nom) as lignes from yourtable d group by d.nom"
$em->getConnection()->query( $sql ); //$em is the entity manager
...

```

I would not use a prepared statement unless you have any parameters (in the sample code you do not).