Original query:

SELECT
  "M".*
FROM
  (
    SELECT
      "M"."Metier O" AS Metier O,
      "M"."Metier D" AS Metier D,
      "M"."Mobilite" AS Mobilite,
      "M"."Type_mobilite" AS Type_mobilite,
      "M"."Specialite O" AS Specialite O,
      "M"."Specialite D" AS Specialite D,
      "M"."Region O" AS Region O,
      "M"."Region D" AS Region D,
      "M"."Annee" AS Annee,
      "M"."id_scenario" AS id_scenario,
      "M"."Scenario" AS Scenario,
      "M"."Libelle_speO" AS Libelle_speO,
      "M"."Libelle_speD" AS Libelle_speD,
      "M"."Statut O" AS Statut O,
      "M"."Statut D" AS Statut D,
      "M"."VizSide" AS Viz Side,
      sum("M"."Nb_moyen") AS Nb_moyen
    FROM
      "gpec"."MobilitesOD-Sankey" M
    GROUP BY
      "M"."Metier O",
      "M"."Metier D",
      "M"."Mobilite",
      "M"."Type_mobilite",
      "M"."Specialite O",
      "M"."Specialite D",
      "M"."Region O",
      "M"."Region D",
      "M"."Annee",
      "M"."id_scenario",
      "M"."Scenario",
      "M"."Libelle_speO",
      "M"."Libelle_speD",
      "M"."Statut O",
      "M"."Statut D",
      "M"."VizSide"
  ) M