pijalu / creaves

Creaves gobuffalo webapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Création de la page statistiques

crealan opened this issue · comments

Dans le menu RAPPORTS creer le page statistique et l'export de statistiques.

date des stats

STAT 1 : NOMBRE D'ANIMAUX ACCUEILLI SELON LE TYPE.

SELECT anit.name AS "Type d'animal",
COUNT(*) AS "Nombre"
From animals AS a
INNER JOIN animaltypes AS anit ON a.animaltype_id = anit.id
WHERE a.created_at BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY a.animaltype_id;

STAT 2: NOMBRE DENTREE SELON LE JOUR DE LA SEMAINE

SELECT Dayofweek(i.date) AS "jour de la semaine",
COUNT(*) AS "Nombre"
FROM intakes AS i
WHERE i.date BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY Dayofweek(i.date)
order by Dayofweek(i.date) ASC;

STAT 3: NOMBRE D'ENTREE SELON LE JOURS DE L'ANNEE

SELECT DATE_FORMAT(i.date, "%Y %m %d") AS "Date d'Entrée",
COUNT(*) AS "Nombre"
From intakes AS i
WHERE i.date BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY DATE_FORMAT(i.date, "%Y %m %d")
ORDER BY DATE_FORMAT(i.date, "%Y %m %d") ASC;

STAT 4: TABLEAU DES ESPECES SORTIE ET AGE

SELECT
a.species AS "espèce",
Count(a.species) AS "NOMBRE",

sum(a.outtake_id is null) AS "Présent",
sum(a.outtake_id is not null) AS "Sorti",

sum(o.outtaketype_id ='83f58302-8fd5-4bce-ac11-8407540d4869') AS "DCD",
sum(o.outtaketype_id ='b40beb00-3840-4735-83c3-2eeedfe8f357') AS "Euthanisié",
sum(o.outtaketype_id ='b28601b2-8ff9-44b4-8ae9-7adbb8c1dac3') AS "Relaché",
sum(o.outtaketype_id ='ea1f0920-ab5b-4e2a-944b-e59eece6bdec') AS "Transferé",

sum(a.animalage_id ='85d68c26-34f5-41ba-8a5f-3bedfe680b65') AS "Bébé",
sum(a.animalage_id ='684529ae-5b1c-4721-88c9-4bceab2a565f') AS "Juvénile",
sum(a.animalage_id ='e722220d-c92c-4373-9f8a-895f5650f3fe') AS "Adulte"

FROM animals AS a
INNER JOIN intakes AS i ON a.intake_id = i.id
INNER JOIN discoveries AS d ON a.discovery_id = d.id
INNER JOIN animalages AS aa ON a.animalage_id = aa.id
LEFT jOIN outtakes AS o ON a.outtake_id = o.id
WHERE i.date BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY a.species
ORDER BY a.species asc;

STAT 5: ENTREE SELON LE MOIS DANS L'ANNEE

SELECT DATE_FORMAT(i.date, "%m") AS "Mois d'Entrée",
COUNT(*) AS "Nombre d'Animaux"
From intakes AS i
WHERE i.date BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY DATE_FORMAT(i.date, "%m")
ORDER BY DATE_FORMAT(i.date, "%m") ASC;

STAT 6: AGE À L'ENTREE

SELECT aa.name AS "Age à l'Entrée",
COUNT(*) AS "Nombre"
From animals AS a
INNER JOIN animalages AS aa ON a.animalage_id = aa.id
WHERE a.created_at BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY a.animalage_id;

STAT 7: SELON LES RAISONS DE SORTIES

SELECT ot.name AS "Type de sortie",
COUNT(*) AS "Nombre"
From animals AS a
INNER JOIN outtakes AS o ON a.outtake_id = o.id
INNER JOIN outtaketypes AS ot ON ot.id = o.outtaketype_id
WHERE a.created_at BETWEEN '2021-01-01' and '2021-12-31'
GROUP BY ot.name;