SELECT DISTINCT ON (sites_pt.codesite)
	sites_pt.gid,
	sites_pt.codesite,
	sites_pt.nom_site,
	ssreq.codsit,
	sites_pt.geom
FROM spatial.sites_pt
LEFT JOIN (SELECT DISTINCT ON (sites_emprise.gid)
			sites_emprise.codsit
			FROM spatial.lignes_electriques_merged, spatial.sites_emprise
			WHERE (st_DWithin(lignes_electriques_merged.geom, sites_emprise.geom, 1000))) ssreq
ON sites_pt.codesite=ssreq.codsit
WHERE ssreq.codsit IS NULL
ORDER BY sites_pt.codesite;