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
|
SELECT libelle_geo,log_tot_10,log_tot_09,log_tot_08,log_tot_07,log_tot_06,log_tot_05,log_tot_04,log_tot_03,log_tot_02,log_tot_01,log_tot_00 FROM(
SELECT
plh.libelle_plh as libelle_geo,
sum(epls.logtot2010) as log_tot_10,
sum(epls.logtot2009) as log_tot_09,
sum(epls.logtot2008) as log_tot_08,
sum(epls.logtot2007) as log_tot_07,
sum(epls.logtot2006) as log_tot_06,
sum(epls.logtot2005) as log_tot_05,
sum(epls.logtot2004) as log_tot_04,
sum(epls.logtot2003) as log_tot_03,
sum(epls.logtot2002) as log_tot_02,
sum(epls.logtot2001) as log_tot_01,
sum(epls.logtot2000) as log_tot_00
FROM
meddtl.epls
JOIN tables_de_references.commune ON meddtl.epls.codgeo = commune.codgeo
JOIN tables_de_references.plh ON commune.plh_ccio = plh.code_plh
GROUP BY plh.code_plh
UNION
SELECT
commune.libelle_commune as libelle_geo,
sum(epls.logtot2010) as log_tot_10,
sum(epls.logtot2009) as log_tot_09,
sum(epls.logtot2008) as log_tot_08,
sum(epls.logtot2007) as log_tot_07,
sum(epls.logtot2006) as log_tot_06,
sum(epls.logtot2005) as log_tot_05,
sum(epls.logtot2004) as log_tot_04,
sum(epls.logtot2003) as log_tot_03,
sum(epls.logtot2002) as log_tot_02,
sum(epls.logtot2001) as log_tot_01,
sum(epls.logtot2000) as log_tot_00
FROM
meddtl.epls
WHERE codgeo IN('17093', '17140')
JOIN tables_de_references.commune ON meddtl.epls.codgeo = commune.codgeo
JOIN tables_de_references.plh ON commune.plh_ccio = plh.code_plh
GROUP BY commune.codgeo) as complet
ORDER BY libelle_geo,log_tot_10; |
Partager