CREATE OR REPLACE VIEW vu_s_sites_details AS
SELECT *
FROM
	s_sites_emprise,
	(SELECT sites_ensemble.objectid, sites_ensemble.code_site, sites_ensemble.libl_site, sites_ensemble.code_ensemble, sites_ensemble.nom_ensemble, sites_ensemble.site_ln, lst_sites_statut.ordre, lst_sites_statut.statut
	FROM 
		(
		SELECT sites.*, ensembles.nom_ensemble FROM sites, ensembles
		WHERE sites.code_ensemble = ensembles.code_ensemble
		) AS sites_ensemble
   JOIN lst_sites_statut ON sites_ensemble.ref_statut = lst_sites_statut.id_statut) sites_statut
WHERE
	s_sites_emprise.codesite = sites_statut.code_site;
