SELECT DISTINCT t.textecontent, h.idhabit, h.type, h.nbpersonne, h.prix, h.ville, h.departement, h.region, h.pays, p.idpers,, i.image, MAX(hp.promotion) as promo, MIN(prixjour) as prix FROM habitation h, habitation_textes t, habitation_images i, habitation_periodes hp, personne p WHERE h.visible=1 AND p.visible = 1 AND p.cgps=1 AND p.valide=1 AND i.diaporama_actif = 1 AND i.diaporama > 0 AND t.textetype = 'titre' AND t.textelang = ':lang' AND t.idhabit = h.idhabit AND h.idhabit = i.idhabit AND h.idpershab = p.idpers AND h.idpershab = p.idpers AND hp.idhabit=h.idhabit AND hp.datefin>'2018-10-17' GROUP BY h.idhabit ORDER BY i.diaporama ASC