Untitled

 avatar
unknown
sql
a year ago
794 B
5
Indexable
	SELECT
		ref_structure.idstructure AS idstructure,
		ref_structure.code AS code,
		ref_structure.nom AS nom,
		ref_structure.ordre AS ordre,
		ref_structure.actif AS actif,
		CONCAT(ref_structure.code , ' - ',ref_structure.nom ) AS affichage,
		idlogin AS idlogin
	FROM
		( SELECT
			idstructure,
			min(idlogin) idlogin
		FROM
			ref_site
			INNER JOIN
			( SELECT
				idsite,
				MAX(idfinanceur) idfinanceur,
				MAX(idlogin) idlogin
			FROM
				ref_loginsite
			%1		--where idlogin = 24
			GROUP BY
				idsite
			) a
			ON ref_site.idsite = a.idsite
			INNER JOIN
			ref_zone
			ON ref_zone.idzone = ref_site.idzone
		GROUP BY
			idstructure
		) b
		INNER JOIN ref_structure
		ON ref_structure.idstructure = b.idstructure
	%2		-- where ref_structure.actif = 1
	ORDER BY ref_structure.ordre
Editor is loading...
Leave a Comment