SELECT SQL_CALC_FOUND_ROWS DISTINCT 
					o2_indexation_bien.id_bien, 
					o2_indexation_bien.id_type, 
					libelle_type_bien,
					o2_indexation_bien.id_commune, 
					o2_indexation_bien.id_departement, 
					o2_indexation_bien.id_region, 
					o2_indexation_bien.id_pays, 
					nb_personnes, 
					nb_chambres,
					prix_standard AS prix_tarif, 
					prix_promo AS prix_promo_tarif, 
					nb_jours, 
					date_deb,
					date_fin
					
					FROM o2_indexation_bien
					LEFT JOIN o2_jours_tarifs ON o2_indexation_bien.id_bien    = o2_jours_tarifs.id_bien
					LEFT JOIN table_type_bien ON o2_indexation_bien.id_type    = table_type_bien.id_type_bien
				
				WHERE 	1
			
					AND o2_jours_tarifs.id_bien IS NOT NULL
					AND o2_indexation_bien.id_type > 0
					AND o2_indexation_bien.id_commune > 0
					AND table_type_bien.actif_type_bien LIKE '1'
				 AND (o2_indexation_bien.id_agence = '77' OR o2_indexation_bien.id_agence = '845' OR o2_indexation_bien.id_agence = '75' OR o2_indexation_bien.id_agence = '71' OR o2_indexation_bien.id_agence = '111' OR o2_indexation_bien.id_agence = '112' OR o2_indexation_bien.id_agence = '152' OR o2_indexation_bien.id_agence = '821' OR o2_indexation_bien.id_agence = '1300' OR o2_indexation_bien.id_agence = '1301' OR o2_indexation_bien.id_agence = '871' OR o2_indexation_bien.id_agence = '1066' OR o2_indexation_bien.id_agence = '81' OR o2_indexation_bien.id_agence = '817' OR o2_indexation_bien.id_agence = '4' OR o2_indexation_bien.id_agence = '185' OR o2_indexation_bien.id_agence = '813' OR o2_indexation_bien.id_agence = '60' OR o2_indexation_bien.id_agence = '78' OR o2_indexation_bien.id_agence = '84' OR o2_indexation_bien.id_agence = '83' OR o2_indexation_bien.id_agence = '45' OR o2_indexation_bien.id_agence = '58' OR o2_indexation_bien.id_agence = '1898' OR o2_indexation_bien.id_agence = '56' OR o2_indexation_bien.id_agence = '1898' OR o2_indexation_bien.id_agence = '79' OR o2_indexation_bien.id_agence = '1948' OR o2_indexation_bien.id_agence = '1929' OR o2_indexation_bien.id_agence = '1905' OR o2_indexation_bien.id_agence = '118' OR o2_indexation_bien.id_agence = '98' OR o2_indexation_bien.id_agence = '1999' OR o2_indexation_bien.id_agence = '1999' OR o2_indexation_bien.id_agence = '1992' OR o2_indexation_bien.id_agence = '2004' OR o2_indexation_bien.id_agence = '2021' OR o2_indexation_bien.id_agence = '2021' OR o2_indexation_bien.id_agence = '2007' OR o2_indexation_bien.id_agence = '2013' OR o2_indexation_bien.id_agence = '2020' OR o2_indexation_bien.id_agence = '1893' OR o2_indexation_bien.id_agence = '2009' OR o2_indexation_bien.id_agence = '109')
 AND o2_jours_tarifs.prix_promo != 0 AND o2_jours_tarifs.prix_promo > 0
						AND o2_jours_tarifs.date_deb >= '2019-03-22' 
						AND o2_jours_tarifs.date_fin <= '2020-02-12' 
					
						AND o2_jours_tarifs.nb_jours >= '7' 
					 AND o2_jours_tarifs.date_fin <= DATE_ADD('2019-03-22', INTERVAL 2 MONTH) 
						AND o2_jours_tarifs.nb_jours <= '7' 
					 GROUP BY o2_indexation_bien.id_bien  ORDER BY o2_indexation_bien.alea_jacta_est, IF(prix_promo >0 AND prix_promo < prix_standard,prix_promo,prix_standard)  LIMIT 0,5