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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
| --------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE IF NOT EXISTS `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
drop table if exists `espece`
--------------
--------------
CREATE TABLE IF NOT EXISTS `espece`
( `id_espece` integer unsigned NOT NULL AUTO_INCREMENT primary key,
`nomBinomial` varchar(255) NOT NULL,
`espece` varchar(255) NOT NULL,
`genre` varchar(255) NOT NULL,
`type_espece` varchar(255) NOT NULL,
`famille` varchar(255) NOT NULL,
`nom_vernac` varchar(255) NOT NULL,
`statuts` varchar(255) NOT NULL,
`utilisation` varchar(255) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `espece` (`nomBinomial`, `espece`, `genre`, `type_espece`, `famille`, `nom_vernac`, `statuts`, `utilisation`) VALUES
('Asterpeia amblyocarpa', 'Asterpeia ', 'amblyocarpa', 'Flore', 'ASTERACEAE', 'Manokamavo,manoky,manoky fotsy,manoky mena,andravo', 'CR', 'Bois de construction (SCHATZ, 1999)'),
('Weinmannia commersonii', 'Weinmannia ', 'commersonii', 'Flore', 'CUNONIACEAE', 'hotraka,lalo,lalona', 'EN', 'Bois de construction,bois de chauffe,fruit comestible'),
('Dalbergia louveli', 'Dalbergia ', 'louveli', 'Flore', 'FABACEAE', 'Andramena', 'EN CITES II', 'Bois d''oeuvre et bois de construction'),
('Dalbergia maritima', 'Dalbergia ', 'maritima', 'Flore', 'FABACEAE', 'Volombodipona,tombobitsy(Antanosy)', 'EN CITES II', 'Bois d''oeuvre et bois de construction'),
('Dalbergia normandii', 'Dalbergia ', 'normandii', 'Flore', 'FABACEAE', 'Voamboana', 'EN CITES II', 'Bois d''oeuvre et bois de construction'),
('Tina thouarsiana', 'Tina ', 'thouarsiana', 'Flore', 'SAPINDACEAE', 'Hazompoza,ramiavondafa,somotrorana', 'EN', 'Bois de construction'),
('Leptolaena multiflora', 'Leptolaena ', 'multiflora', 'Flore', 'SARCOLAENACEAE', 'Anjananjana,azananzana,birana,dilatra', 'EN', 'Bois de construction'),
('Calophyllum chapelieri', 'Calophyllum ', 'chapelieri', 'Flore', 'ANACARDIACEAE', 'Foraha,makaleony,sorapaha,vintanina,vintaninaberav', 'VU', 'Bois de construction et manche à outil'),
('Symphonia fasciculata', 'Symphonia ', 'fasciculata', 'Flore', 'CLUSIACEAE', 'Hazimberavina,hazina,hazinibe,kijy,kizavavy,fatra', 'VU', 'Bois de construction,bois de chauffe,huile essentielle,plante medicinale'),
('Cordyla haraka', 'Cordyla ', 'haraka', 'Flore', 'FABACEAE', 'Haraka', 'VU', 'Manche à outil,gaulette,cercueil'),
('Dalbergia baroni', 'Dalbergia ', 'baroni', 'Flore', 'FABACEAE', 'Hazovolo,voamboana', 'VU CITES II', 'Bois d''oeuvre et bois de construction'),
('Dalbergia chapelieri', 'Dalbergia ', 'chapelieri', 'Flore', 'FABACEAE', 'Savoka,soroka,sovoka', 'VU CITES II', 'Bois d''oeuvre et bois de construction'),
('Dalbergia madagascariensis', 'Dalbergia ', 'madagascariensis', 'Flore', 'FABACEAE', 'Hazovola,hazovola mena,hazovolo,manary,manary be,m', 'VU CITES II', 'Bois d''oeuvre et bois de construction'),
('Dalbergia monticola', 'Dalbergia ', 'monticola', 'Flore', 'FABACEAE', 'Voamboana(Perinet);Hazovola(Maroantsetra);Tsiandal', 'VU CITES II', 'Bois d''oeuvre et bois de construction'),
('Labramia bojeri', 'Labramia ', 'bojeri', 'Flore', 'SAPOTACEAE', 'Felambarika,fotajana', 'VU', 'Bois de construction'),
('Canarium lamianum', 'Canarium ', 'lamianum', 'Flore', 'BURSERACEAE', 'Ramy', 'DD', 'Bois de construction'),
('Canarium obovatum', 'Canarium ', 'obovatum', 'Flore', 'BURSERACEAE', 'Ramy', 'DD', 'Bois de construction,manche à outil,gaulette,production de gomme'),
('Ocotea alveolata', 'Ocotea ', 'alveolata', 'Flore', 'LAURACEAE', 'Varongy,varongilahy,varongimainty,varongimena', 'DD', 'Bois d''oeuvre et bois de construction'),
('Ocotea racemosa', 'Ocotea ', 'racemosa', 'Flore', 'LAURACEAE', 'Varongifotsy,varongikely,varongilahy,varongimainty', 'DD', 'Bois d''oeuvre et bois de construction,fruit comestible'),
('Faucherea tampolensis', 'Faucherea ', 'tampolensis', 'Flore', 'SAPOTACEAE', 'Nanto,nantobariatra,natobariatra,natoboraka,natoji', 'DD', 'Bois de construction'),
('Ardeola idea ', 'Ardeola ', 'idea ', 'Faune', 'ARDEIDAE', 'Héron crabier blanc', 'Attraction touristique', 'EN')
--------------
--------------
select * from `espece`
--------------
+-----------+----------------------------+--------------+------------------+-------------+----------------+----------------------------------------------------+------------------------+--------------------------------------------------------------------------+
| id_espece | nomBinomial | espece | genre | type_espece | famille | nom_vernac | statuts | utilisation |
+-----------+----------------------------+--------------+------------------+-------------+----------------+----------------------------------------------------+------------------------+--------------------------------------------------------------------------+
| 1 | Asterpeia amblyocarpa | Asterpeia | amblyocarpa | Flore | ASTERACEAE | Manokamavo,manoky,manoky fotsy,manoky mena,andravo | CR | Bois de construction (SCHATZ, 1999) |
| 2 | Weinmannia commersonii | Weinmannia | commersonii | Flore | CUNONIACEAE | hotraka,lalo,lalona | EN | Bois de construction,bois de chauffe,fruit comestible |
| 3 | Dalbergia louveli | Dalbergia | louveli | Flore | FABACEAE | Andramena | EN CITES II | Bois d'oeuvre et bois de construction |
| 4 | Dalbergia maritima | Dalbergia | maritima | Flore | FABACEAE | Volombodipona,tombobitsy(Antanosy) | EN CITES II | Bois d'oeuvre et bois de construction |
| 5 | Dalbergia normandii | Dalbergia | normandii | Flore | FABACEAE | Voamboana | EN CITES II | Bois d'oeuvre et bois de construction |
| 6 | Tina thouarsiana | Tina | thouarsiana | Flore | SAPINDACEAE | Hazompoza,ramiavondafa,somotrorana | EN | Bois de construction |
| 7 | Leptolaena multiflora | Leptolaena | multiflora | Flore | SARCOLAENACEAE | Anjananjana,azananzana,birana,dilatra | EN | Bois de construction |
| 8 | Calophyllum chapelieri | Calophyllum | chapelieri | Flore | ANACARDIACEAE | Foraha,makaleony,sorapaha,vintanina,vintaninaberav | VU | Bois de construction et manche à outil |
| 9 | Symphonia fasciculata | Symphonia | fasciculata | Flore | CLUSIACEAE | Hazimberavina,hazina,hazinibe,kijy,kizavavy,fatra | VU | Bois de construction,bois de chauffe,huile essentielle,plante medicinale |
| 10 | Cordyla haraka | Cordyla | haraka | Flore | FABACEAE | Haraka | VU | Manche à outil,gaulette,cercueil |
| 11 | Dalbergia baroni | Dalbergia | baroni | Flore | FABACEAE | Hazovolo,voamboana | VU CITES II | Bois d'oeuvre et bois de construction |
| 12 | Dalbergia chapelieri | Dalbergia | chapelieri | Flore | FABACEAE | Savoka,soroka,sovoka | VU CITES II | Bois d'oeuvre et bois de construction |
| 13 | Dalbergia madagascariensis | Dalbergia | madagascariensis | Flore | FABACEAE | Hazovola,hazovola mena,hazovolo,manary,manary be,m | VU CITES II | Bois d'oeuvre et bois de construction |
| 14 | Dalbergia monticola | Dalbergia | monticola | Flore | FABACEAE | Voamboana(Perinet);Hazovola(Maroantsetra);Tsiandal | VU CITES II | Bois d'oeuvre et bois de construction |
| 15 | Labramia bojeri | Labramia | bojeri | Flore | SAPOTACEAE | Felambarika,fotajana | VU | Bois de construction |
| 16 | Canarium lamianum | Canarium | lamianum | Flore | BURSERACEAE | Ramy | DD | Bois de construction |
| 17 | Canarium obovatum | Canarium | obovatum | Flore | BURSERACEAE | Ramy | DD | Bois de construction,manche à outil,gaulette,production de gomme |
| 18 | Ocotea alveolata | Ocotea | alveolata | Flore | LAURACEAE | Varongy,varongilahy,varongimainty,varongimena | DD | Bois d'oeuvre et bois de construction |
| 19 | Ocotea racemosa | Ocotea | racemosa | Flore | LAURACEAE | Varongifotsy,varongikely,varongilahy,varongimainty | DD | Bois d'oeuvre et bois de construction,fruit comestible |
| 20 | Faucherea tampolensis | Faucherea | tampolensis | Flore | SAPOTACEAE | Nanto,nantobariatra,natobariatra,natoboraka,natoji | DD | Bois de construction |
| 21 | Ardeola idea | Ardeola | idea | Faune | ARDEIDAE | Héron crabier blanc | Attraction touristique | EN |
+-----------+----------------------------+--------------+------------------+-------------+----------------+----------------------------------------------------+------------------------+--------------------------------------------------------------------------+
--------------
commit
--------------
--------------
drop table if exists `site_coketes`
--------------
--------------
CREATE TABLE IF NOT EXISTS `site_coketes`
( `id_sitecoketes` integer unsigned NOT NULL AUTO_INCREMENT primary key,
`nom_sitecoketes` varchar(255) NOT NULL,
`superficie_sitecoketes` decimal(15,2) DEFAULT NULL,
`statut` varchar(255) DEFAULT NULL,
`etat` integer unsigned DEFAULT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `site_coketes` (`nom_sitecoketes`, `superficie_sitecoketes`, `statut`, `etat`) VALUES
('Tampolo', NULL, 'Nouvelle aire protégée', 1),
('Pointe à Larrée', NULL, 'Nouvelle aire protégée', 1),
('Betampona', NULL, 'Réserve naturelle intégrale', 1),
('Manombo', NULL, 'Réserve spéciale', 1),
('Agnalazaha(Mahabo mananivo)', NULL, 'Nouvelle aire protégée', 1),
('Ambongamarina', 0.00, '', 1),
('Tsiazompaniry', NULL, NULL, 1),
('Bekorakaka', NULL, NULL, 1),
('Sandrandahy', NULL, NULL, 1),
('Ranomafana', NULL, 'Parc national', 1),
('Mahavavy Kinkony', NULL, 'Nouvelle aire protégée', 1),
('Ankarafantsika', NULL, 'Parc national', 1),
('Bemanevika', NULL, 'Aire protégée', 1),
('Mandrozo', NULL, 'Aire protégée', 1),
('Tsimembo Manambolomaty', NULL, 'Aire protégée', 1),
('Ambondrobe(Ankevo)', NULL, 'Nouvelle aire protégée', 1),
('Tsimbazaza', NULL, 'Parc', 1),
('Central', NULL, NULL, 1)
--------------
--------------
select * from `site_coketes`
--------------
+----------------+-----------------------------+------------------------+-----------------------------+------+
| id_sitecoketes | nom_sitecoketes | superficie_sitecoketes | statut | etat |
+----------------+-----------------------------+------------------------+-----------------------------+------+
| 1 | Tampolo | NULL | Nouvelle aire protégée | 1 |
| 2 | Pointe à Larrée | NULL | Nouvelle aire protégée | 1 |
| 3 | Betampona | NULL | Réserve naturelle intégrale | 1 |
| 4 | Manombo | NULL | Réserve spéciale | 1 |
| 5 | Agnalazaha(Mahabo mananivo) | NULL | Nouvelle aire protégée | 1 |
| 6 | Ambongamarina | 0.00 | | 1 |
| 7 | Tsiazompaniry | NULL | NULL | 1 |
| 8 | Bekorakaka | NULL | NULL | 1 |
| 9 | Sandrandahy | NULL | NULL | 1 |
| 10 | Ranomafana | NULL | Parc national | 1 |
| 11 | Mahavavy Kinkony | NULL | Nouvelle aire protégée | 1 |
| 12 | Ankarafantsika | NULL | Parc national | 1 |
| 13 | Bemanevika | NULL | Aire protégée | 1 |
| 14 | Mandrozo | NULL | Aire protégée | 1 |
| 15 | Tsimembo Manambolomaty | NULL | Aire protégée | 1 |
| 16 | Ambondrobe(Ankevo) | NULL | Nouvelle aire protégée | 1 |
| 17 | Tsimbazaza | NULL | Parc | 1 |
| 18 | Central | NULL | NULL | 1 |
+----------------+-----------------------------+------------------------+-----------------------------+------+
--------------
commit
--------------
--------------
drop table if exists `espececible_suivi`
--------------
--------------
CREATE TABLE IF NOT EXISTS `espececible_suivi`
( `id_espececible_suivi` integer unsigned NOT NULL AUTO_INCREMENT primary key,
`numero_espececible` varchar(255) NOT NULL,
`longitude` varchar(255) NOT NULL,
`latitude` varchar(255) NOT NULL,
`altitude` varchar(255) NOT NULL,
`id_espece` integer unsigned NOT NULL,
`id_sitecoketes` integer unsigned NOT NULL,
CONSTRAINT `FK_site_coketes` FOREIGN KEY (`id_sitecoketes`) REFERENCES `site_coketes` (`id_sitecoketes`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_espece` FOREIGN KEY (`id_espece`) REFERENCES `espece` (`id_espece`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `espececible_suivi` (`numero_espececible`, `longitude`, `latitude`, `altitude`, `id_espece`, `id_sitecoketes`) VALUES
('01', '1', '1', '1', 13, 3)
--------------
--------------
select * from `site_coketes`
--------------
+----------------+-----------------------------+------------------------+-----------------------------+------+
| id_sitecoketes | nom_sitecoketes | superficie_sitecoketes | statut | etat |
+----------------+-----------------------------+------------------------+-----------------------------+------+
| 1 | Tampolo | NULL | Nouvelle aire protégée | 1 |
| 2 | Pointe à Larrée | NULL | Nouvelle aire protégée | 1 |
| 3 | Betampona | NULL | Réserve naturelle intégrale | 1 |
| 4 | Manombo | NULL | Réserve spéciale | 1 |
| 5 | Agnalazaha(Mahabo mananivo) | NULL | Nouvelle aire protégée | 1 |
| 6 | Ambongamarina | 0.00 | | 1 |
| 7 | Tsiazompaniry | NULL | NULL | 1 |
| 8 | Bekorakaka | NULL | NULL | 1 |
| 9 | Sandrandahy | NULL | NULL | 1 |
| 10 | Ranomafana | NULL | Parc national | 1 |
| 11 | Mahavavy Kinkony | NULL | Nouvelle aire protégée | 1 |
| 12 | Ankarafantsika | NULL | Parc national | 1 |
| 13 | Bemanevika | NULL | Aire protégée | 1 |
| 14 | Mandrozo | NULL | Aire protégée | 1 |
| 15 | Tsimembo Manambolomaty | NULL | Aire protégée | 1 |
| 16 | Ambondrobe(Ankevo) | NULL | Nouvelle aire protégée | 1 |
| 17 | Tsimbazaza | NULL | Parc | 1 |
| 18 | Central | NULL | NULL | 1 |
+----------------+-----------------------------+------------------------+-----------------------------+------+
--------------
commit
--------------
--------------
drop table if exists `feuillaison`
--------------
--------------
CREATE TABLE IF NOT EXISTS `feuillaison`
( `id_feuillaison` integer unsigned NOT NULL AUTO_INCREMENT primary key,
`stade_feuillaison` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `feuillaison` (`stade_feuillaison`, `description`) VALUES
('Stade V0', 'rameaux nus, sans feuilles'),
('Stade V1', 'formation des bourgeons foliaires'),
('Stade V2', 'bourgeons foliaires + feuilles épanouies'),
('Stade V3', 'feuillage développé et abondant sur rameaux'),
('Stade V4', 'feuilles vertes + feuilles sèches ou ayant changé de couleur'),
('Stade V5', 'plus de 50% des organes dc l''individu ont des feuilles sèches et chute des feuilles')
--------------
--------------
select * from `feuillaison`
--------------
+----------------+-------------------+-------------------------------------------------------------------------------------+
| id_feuillaison | stade_feuillaison | description |
+----------------+-------------------+-------------------------------------------------------------------------------------+
| 1 | Stade V0 | rameaux nus, sans feuilles |
| 2 | Stade V1 | formation des bourgeons foliaires |
| 3 | Stade V2 | bourgeons foliaires + feuilles épanouies |
| 4 | Stade V3 | feuillage développé et abondant sur rameaux |
| 5 | Stade V4 | feuilles vertes + feuilles sèches ou ayant changé de couleur |
| 6 | Stade V5 | plus de 50% des organes dc l'individu ont des feuilles sèches et chute des feuilles |
+----------------+-------------------+-------------------------------------------------------------------------------------+
--------------
commit
--------------
--------------
drop table if exists `suivi_espece_cible`
--------------
--------------
CREATE TABLE IF NOT EXISTS `suivi_espece_cible`
( `id_suivi_espececible` integer unsigned NOT NULL AUTO_INCREMENT primary key,
`date_suivi_espece_cible` date DEFAULT NULL,
`observation_espececible` text NOT NULL,
`id_espececible_suivi` integer unsigned DEFAULT NULL,
`id_feuillaison` integer unsigned DEFAULT NULL,
CONSTRAINT `FK_id_feuillaison` FOREIGN KEY (`id_feuillaison`) REFERENCES `feuillaison` (`id_feuillaison`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_espececible_suivi` FOREIGN KEY (`id_espececible_suivi`) REFERENCES `espececible_suivi` (`id_espececible_suivi`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `suivi_espece_cible` (`date_suivi_espece_cible`, `observation_espececible`, `id_espececible_suivi`,`id_feuillaison`) VALUES
('2019-10-13', 'ok', 1, 3),
('2019-10-01', 'ok', 1, 4),
('2019-10-31', 'ok', 1, 4),
('2019-10-30', 'ok', 1, 3),
('2019-10-31', 'ok', 1, 3),
('2019-10-31', 'ok', 1, 2),
('2019-10-30', 'ok', 1, 4),
('2019-11-11', 'ok', 1, 1)
--------------
--------------
select * from `suivi_espece_cible`
--------------
+----------------------+-------------------------+-------------------------+----------------------+----------------+
| id_suivi_espececible | date_suivi_espece_cible | observation_espececible | id_espececible_suivi | id_feuillaison |
+----------------------+-------------------------+-------------------------+----------------------+----------------+
| 1 | 2019-10-13 | ok | 1 | 3 |
| 2 | 2019-10-01 | ok | 1 | 4 |
| 3 | 2019-10-31 | ok | 1 | 4 |
| 4 | 2019-10-30 | ok | 1 | 3 |
| 5 | 2019-10-31 | ok | 1 | 3 |
| 6 | 2019-10-31 | ok | 1 | 2 |
| 7 | 2019-10-30 | ok | 1 | 4 |
| 8 | 2019-11-11 | ok | 1 | 1 |
+----------------------+-------------------------+-------------------------+----------------------+----------------+
--------------
commit
--------------
--------------
drop view if exists `vue_mois`
--------------
--------------
create view `vue_mois` as
select t1.stade_feuillaison,
t3.id_espece,
year(t2.date_suivi_espece_cible) as annee,
sum(case when month(t2.date_suivi_espece_cible) = 01 then 1 else 0 end) as janvier,
sum(case when month(t2.date_suivi_espece_cible) = 02 then 1 else 0 end) as fevrier,
sum(case when month(t2.date_suivi_espece_cible) = 03 then 1 else 0 end) as mars,
sum(case when month(t2.date_suivi_espece_cible) = 04 then 1 else 0 end) as avril,
sum(case when month(t2.date_suivi_espece_cible) = 05 then 1 else 0 end) as mai,
sum(case when month(t2.date_suivi_espece_cible) = 06 then 1 else 0 end) as juin,
sum(case when month(t2.date_suivi_espece_cible) = 07 then 1 else 0 end) as juillet,
sum(case when month(t2.date_suivi_espece_cible) = 08 then 1 else 0 end) as aout,
sum(case when month(t2.date_suivi_espece_cible) = 09 then 1 else 0 end) as septembre,
sum(case when month(t2.date_suivi_espece_cible) = 10 then 1 else 0 end) as octobre,
sum(case when month(t2.date_suivi_espece_cible) = 11 then 1 else 0 end) as novembre,
sum(case when month(t2.date_suivi_espece_cible) = 12 then 1 else 0 end) as decembre
from `feuillaison` as t1
inner join `suivi_espece_cible` as t2
on t2.id_feuillaison = t1.id_feuillaison
inner join `espececible_suivi` as t3
on t3.id_espececible_suivi = t2.id_espececible_suivi
group by t1.stade_feuillaison, t3.id_espece, annee
--------------
--------------
select * from `vue_mois`
--------------
+-------------------+-----------+-------+---------+---------+------+-------+------+------+---------+------+-----------+---------+----------+----------+
| stade_feuillaison | id_espece | annee | janvier | fevrier | mars | avril | mai | juin | juillet | aout | septembre | octobre | novembre | decembre |
+-------------------+-----------+-------+---------+---------+------+-------+------+------+---------+------+-----------+---------+----------+----------+
| Stade V2 | 13 | 2019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 |
| Stade V3 | 13 | 2019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 |
| Stade V1 | 13 | 2019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| Stade V0 | 13 | 2019 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
+-------------------+-----------+-------+---------+---------+------+-------+------+------+---------+------+-----------+---------+----------+----------+
--------------
select stade_feuillaison,
octobre,
novembre
from `vue_mois`
where annee = 2019
and id_espece = 13
union
select 'total' as stade_feuillaison,
sum(octobre) as octobre,
sum(novembre) as novembre
from `vue_mois`
where annee = 2019
and id_espece = 13
order by stade_feuillaison asc
--------------
+-------------------+---------+----------+
| stade_feuillaison | octobre | novembre |
+-------------------+---------+----------+
| Stade V0 | 0 | 1 |
| Stade V1 | 1 | 0 |
| Stade V2 | 3 | 0 |
| Stade V3 | 3 | 0 |
| total | 7 | 1 |
+-------------------+---------+----------+
--------------
drop view if exists `vue_annee`
--------------
--------------
create view `vue_annee` as
select t1.stade_feuillaison,
sum(case when year(t2.date_suivi_espece_cible) = 2018 then 1 else 0 end) as A2018,
sum(case when year(t2.date_suivi_espece_cible) = 2019 then 1 else 0 end) as A2019
from `feuillaison` as t1
inner join `suivi_espece_cible` as t2
on t2.id_feuillaison = t1.id_feuillaison
inner join `espececible_suivi` as t3
on t3.id_espececible_suivi = t2.id_espececible_suivi
where t3.id_espece = 13
group by t1.stade_feuillaison
--------------
--------------
select * from `vue_annee`
--------------
+-------------------+-------+-------+
| stade_feuillaison | A2018 | A2019 |
+-------------------+-------+-------+
| Stade V0 | 0 | 1 |
| Stade V1 | 0 | 1 |
| Stade V2 | 0 | 3 |
| Stade V3 | 0 | 3 |
+-------------------+-------+-------+
--------------
select stade_feuillaison,
A2018,
A2019
from `vue_annee`
union
select 'total' as stade_feuillaison,
sum(A2018) as A2018,
sum(A2019) as A2019
from `vue_annee`
order by stade_feuillaison asc
--------------
+-------------------+-------+-------+
| stade_feuillaison | A2018 | A2019 |
+-------------------+-------+-------+
| Stade V0 | 0 | 1 |
| Stade V1 | 0 | 1 |
| Stade V2 | 0 | 3 |
| Stade V3 | 0 | 3 |
| total | 0 | 8 |
+-------------------+-------+-------+
--------------
COMMIT
--------------
Appuyez sur une touche pour continuer... |
Partager