public function get_group_by(array $cfg): string
  {
    $res = '';
    $group_to_put = [];
    if ( !empty($cfg['group_by']) ){
      foreach ( $cfg['group_by'] as $g ){
        if ( isset($cfg['available_fields'][$g]) ){
          $group_to_put[] = $this->escape($g);
          //$group_to_put[] = $this->col_full_name($g, $cfg['available_fields'][$g], true);
        }
        else{
          $this->db->error("Error! The column '$g' doesn't exist for group by ".print_r($cfg, true));
        }
      }
      if ( count($group_to_put) ){
        $res .= 'GROUP BY '.implode(', ', $group_to_put).PHP_EOL;
      }
    }
    return $res;
  }