CREATE TABLE spatial.v41002_gille_nbsp_biblio AS
(
SELECT gid,
	maillemax.*,
	the_geom
FROM spatial.v41002_grille_250m
JOIN (SELECT 
		v41002_grille_250m."ID" AS id_maille,
		MAX ("v41002_flore_2002_nbSP"."NB_SP") AS nb_sp_max
	FROM spatial."v41002_flore_2002_nbSP", spatial.v41002_grille_250m
	WHERE st_intersects("v41002_flore_2002_nbSP".the_geom, v41002_grille_250m.the_geom)
	GROUP BY (id_maille)
	) AS maillemax
ON maillemax.id_maille=v41002_grille_250m."ID"
ORDER BY id_maille
)