select exemplaires.expl_cb as "code-barres", year(arc_debut) as année, case when month(arc_debut) in (1, 2, 3) then "trimestre 1" when month(arc_debut) in (4,5,6) then "trimestre 2" when month(arc_debut) in (7, 8, 9) then "trimestre 3" when month(arc_debut) in (10, 11, 12) then "trimestre 4" end as trimestre, count(arc_id) as "Nombre de prêts" from exemplaires  left join pret_archive on arc_expl_id=expl_id where expl_cb like "!!codebarreexpl!!" and year(NOW())-year(arc_debut) < 3 group by année, trimestre, expl_cb order by 1, 2, 3 