select empr_prenom as "Prénom", empr_nom as "Nom" , case type_compte_id when '1' then "Abonnement" when '2' then "Amende" when '3' then "Prêt" end as "Type de compte", date_format(date_enrgt, '%d-%m-%Y') as "Date", case when sens='1' then 'Crédit' else 'Débit' end as "Débit/Crédit", (montant*sens) as "Montant", commentaire as "Commentaires" from transactions, comptes, empr where compte_id=id_compte and id_empr=proprio_id and if('!!empr!!'='0', '1', id_empr='!!empr!!') and if(!!typcom!!='0', '1', type_compte_id=!!typcom!!) and date_format(date_enrgt, '%Y%m%d') >= date_format('!!date_debut!!', '%Y%m%d') and date_format(date_enrgt, '%Y%m%d') <= date_format('!!date_fin!!', '%Y%m%d') order by empr_nom, empr_prenom, type_compte_id, date_enrgt desc