 			THEN s.id_nomenclature_life_stage
 		ELSE NULL
 		END AS id_nomenclature_life_stage,
-	tar.id_altitude_range AS id_altitude_range,
-	count(s.*) AS count_valid_data 
+	count(s.*) AS count_valid_data,
+	min(s.altitude_min) as extreme_altitude_min,
+	array_agg(s.altitude_min order by s.altitude_min ASC) as my_alt_min,
+	max(s.altitude_max) as extreme_altitude_max,
+	array_agg(s.altitude_max order by s.altitude_max DESC) as my_alt_max
 FROM gn_synthese.synthese s
 LEFT JOIN taxonomie.taxref t ON s.cd_nom=t.cd_nom
-LEFT JOIN gn_profiles.t_altitude_ranges tar ON s.altitude_min <= tar.alt_max AND 
-	s.altitude_max >= tar.alt_min
 CROSS JOIN gn_profiles.get_parameters(s.cd_nom) p
 WHERE p.temporal_precision_days IS NOT NULL 
 	AND p.spatial_precision  IS NOT NULL

ALTER TABLE ONLY gn_profiles.cor_taxons_parameters 
	ADD CONSTRAINT pk_taxons_parameters PRIMARY KEY (cd_nom);

ALTER TABLE ONLY gn_profiles.t_altitude_ranges 
	ADD CONSTRAINT pk_altitude_range PRIMARY KEY (id_altitude_range);


-----------------
-- CONSTRAINTS --
-----------------

					WHEN p.active_life_stage=true THEN s.id_nomenclature_life_stage
					ELSE NULL
					END AS id_nomenclature_life_stage,
				s.altitude_min,
				s.altitude_max
			FROM gn_synthese.synthese s
			LEFT JOIN taxonomie.taxref t ON s.cd_nom=t.cd_nom
			CROSS JOIN gn_profiles.get_parameters(s.cd_nom) p
			WHERE s.id_synthese=myidsynthese
				AND p.temporal_precision_days IS NOT NULL 
