1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| select 'de 16 à 20 ans' as 'intervalle',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`)<=30,1,0) ) as '< mois',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`) between 31 and 60,1,0)) as ' > mois et 02 mois',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`) between 61 and 90,1,0)) as ' ',
.......
FROM
`t_emprunteur`
INNER JOIN `t_emprunt` ON (`t_emprunteur.`num_empr` = `t_emprunt`.`num_empr`)
where
and (year(curdate())-substring(`t_emprunteur`.`dat_naissance`,1,4) between 16 and 20)
UNION
select 'de 21 à 25 ans' as 'intervalle',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`)<=30,1,0) ) as '< mois',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`) between 31 and 60,1,0)) as ' > mois et 02 mois',
sum(if(datediff( `t_emprunt`.`date_fin_empr`, `t_emprunt`.`date_debut_empr`) between 61 and 90,1,0)) as ' ',
.......
FROM
`t_emprunteur`
INNER JOIN `t_emprunt` ON (`t_emprunteur.`num_empr` = `t_emprunt`.`num_empr`)
where
and (year(curdate())-substring(`t_emprunteur`.`dat_naissance`,1,4) between 21 and 25)
UNION
... |
Partager