How do I use "GROUP BY"? How do I use GROUP BY to display the result by group (email)?
this is my file .php

&lt;?php
/**
 * Created by PhpStorm.
 */
namespace Drupal\gestion_contact\Controller;
use Drupal\Core\Controller\ControllerBase;
class GestionContactController extends ControllerBase
{
    public function admin() {


        $result = db_query("SELECT * FROM {contact}");

            $node = $result-&gt;fetchAll();

        return array(
            '#theme' =&gt; 'gestion_contact',
            '#nodes'=&gt; $node,

        );
    }
    public function delete($id)
    {

        db_delete('contact')
            -&gt;condition('id_contact', $id)
            -&gt;execute();
        drupal_set_message(t('Your form has been deleted'));

        $result = db_query("SELECT * FROM {contact}");

        $node = $result-&gt;fetchAll();
        return array(
            '#theme' =&gt; 'gestion_contact',
            '#nodes' =&gt; $node,

        );
    }
    public function afficher()
    {

        $result = db_query("SELECT * FROM {contact} WHERE vu = :vu",
            array(':vu' =&gt; 'false'));
        $node = $result-&gt;fetchAll();
        return array(
            '#theme' =&gt; 'nouveaux_contact',
            '#nodes' =&gt; $node,
        );
    }
}
Follow an example:

$result = db_query('SELECT tid, count(tid) AS count FROM {taxonomy_term_field_data} WHERE vid &lt;&gt; :vid GROUP BY tid', array(':vid' =&gt; 'tags'));


But, from docs...


  Deprecated
  
  as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a
  database connection injected into your service from the container and
  call query() on it. For example, $injected_database->query($query,
  $args, $options);


More info in db_query.  

Edit 1:

Drupal set by default sql_mode with 'only_full_group_by', in your case when you use SELECT *, an database exception is throw, look in your log, you will see something like this:


  Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'database.table.field' which is not functionally dependent on columns in GROUP BY clause.


So to correct this you must aggregate all fields in your SELECT list. If you only need e-mail list something like this can solve:

db_query('SELECT email FROM {contact} GROUP BY email');