Changes between Version 21 and Version 22 of Recette SQL SommeEffectifs


Ignore:
Timestamp:
May 20, 2016 5:23:58 PM (9 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Recette SQL SommeEffectifs

    v21 v22  
    103103||Silurus glanis||3|||| 
    104104||Tinca tinca||1|||| 
     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/* 
     111requete complete 
     112*/ 
     113with lot_ope_detail as ( 
     114SELECT t_operation_ope.ope_identifiant, t_lot_lot.lot_identifiant, t_operation_ope.ope_dic_identifiant,  
     115t_lot_lot.lot_lot_identifiant AS lot_pere, t_operation_ope.ope_date_debut, t_operation_ope.ope_date_fin,  
     116t_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,  
     117tr_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) 
     124select * from lot_ope_detail 
     125 
     126 
     127/* 
     128Somme des effectifs de civelles sur les deux passes d'Arzal par mois 
     129*/ 
     130 
     131with lot_ope_detail as ( 
     132SELECT t_operation_ope.ope_identifiant, t_lot_lot.lot_identifiant, t_operation_ope.ope_dic_identifiant,  
     133t_lot_lot.lot_lot_identifiant AS lot_pere, t_operation_ope.ope_date_debut, t_operation_ope.ope_date_fin,  
     134t_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,  
     135tr_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 
     143select  sum(s.lot_quantite),s.annee,s.mois from( 
     144select *, extract(month from ope_date_debut) as mois,extract(year from ope_date_debut) as annee  from lot_ope_detail 
     145where lot_tax_code='2038' 
     146and (ope_dic_identifiant=6 or ope_dic_identifiant=12) 
     147and lot_quantite is not null 
     148and lot_std_code='CIV' 
     149) as s 
     150group by s.annee,s.mois 
     151order by s.annee,s.mois 
     152 
     153}}}