| 105 | |
| 106 | |
| 107 | [[BR]] |
| 108 | == Somme des effectifs de civelles sur les deux passes du barrage d'Arzal par mois et années == |
| 109 | {{{ |
| 110 | /* |
| 111 | requete complete |
| 112 | */ |
| 113 | with lot_ope_detail as ( |
| 114 | SELECT t_operation_ope.ope_identifiant, t_lot_lot.lot_identifiant, t_operation_ope.ope_dic_identifiant, |
| 115 | t_lot_lot.lot_lot_identifiant AS lot_pere, t_operation_ope.ope_date_debut, t_operation_ope.ope_date_fin, |
| 116 | t_lot_lot.lot_effectif, t_lot_lot.lot_quantite, t_lot_lot.lot_tax_code, t_lot_lot.lot_std_code, tr_taxon_tax.tax_nom_latin, |
| 117 | tr_stadedeveloppement_std.std_libelle, tr_devenirlot_dev.dev_code, tr_devenirlot_dev.dev_libelle |
| 118 | FROM iav.t_operation_ope |
| 119 | JOIN iav.t_lot_lot ON t_lot_lot.lot_ope_identifiant = t_operation_ope.ope_identifiant |
| 120 | LEFT JOIN ref.tr_typequantitelot_qte ON tr_typequantitelot_qte.qte_code::text = t_lot_lot.lot_qte_code::text |
| 121 | LEFT JOIN ref.tr_devenirlot_dev ON tr_devenirlot_dev.dev_code::text = t_lot_lot.lot_dev_code::text |
| 122 | JOIN ref.tr_taxon_tax ON tr_taxon_tax.tax_code::text = t_lot_lot.lot_tax_code::text |
| 123 | JOIN ref.tr_stadedeveloppement_std ON tr_stadedeveloppement_std.std_code::text = t_lot_lot.lot_std_code::text) |
| 124 | select * from lot_ope_detail |
| 125 | |
| 126 | |
| 127 | /* |
| 128 | Somme des effectifs de civelles sur les deux passes d'Arzal par mois |
| 129 | */ |
| 130 | |
| 131 | with lot_ope_detail as ( |
| 132 | SELECT t_operation_ope.ope_identifiant, t_lot_lot.lot_identifiant, t_operation_ope.ope_dic_identifiant, |
| 133 | t_lot_lot.lot_lot_identifiant AS lot_pere, t_operation_ope.ope_date_debut, t_operation_ope.ope_date_fin, |
| 134 | t_lot_lot.lot_effectif, t_lot_lot.lot_quantite, t_lot_lot.lot_tax_code, t_lot_lot.lot_std_code, tr_taxon_tax.tax_nom_latin, |
| 135 | tr_stadedeveloppement_std.std_libelle, tr_devenirlot_dev.dev_code, tr_devenirlot_dev.dev_libelle |
| 136 | FROM iav.t_operation_ope |
| 137 | JOIN iav.t_lot_lot ON t_lot_lot.lot_ope_identifiant = t_operation_ope.ope_identifiant |
| 138 | LEFT JOIN ref.tr_typequantitelot_qte ON tr_typequantitelot_qte.qte_code::text = t_lot_lot.lot_qte_code::text |
| 139 | LEFT JOIN ref.tr_devenirlot_dev ON tr_devenirlot_dev.dev_code::text = t_lot_lot.lot_dev_code::text |
| 140 | JOIN ref.tr_taxon_tax ON tr_taxon_tax.tax_code::text = t_lot_lot.lot_tax_code::text |
| 141 | JOIN ref.tr_stadedeveloppement_std ON tr_stadedeveloppement_std.std_code::text = t_lot_lot.lot_std_code::text) |
| 142 | |
| 143 | select sum(s.lot_quantite),s.annee,s.mois from( |
| 144 | select *, extract(month from ope_date_debut) as mois,extract(year from ope_date_debut) as annee from lot_ope_detail |
| 145 | where lot_tax_code='2038' |
| 146 | and (ope_dic_identifiant=6 or ope_dic_identifiant=12) |
| 147 | and lot_quantite is not null |
| 148 | and lot_std_code='CIV' |
| 149 | ) as s |
| 150 | group by s.annee,s.mois |
| 151 | order by s.annee,s.mois |
| 152 | |
| 153 | }}} |