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
| with test as (
select
Région,
[Global Dimension 1] as Agence,
No_,
case
when No_ like 'des.%' then '1'
end as Nb_Devis,
case
when No_ like 'prj.%' then '1'
end as Nb_Affaires,
case
when No_ like 'des.%' then [Creation Date]
when No_ like 'prj.%' then [Date de commande]
end as Date,
[Person Responsible]as Ing,
[Date de commande] as Commandes,
[Montant Devis] as Montant,
[Montant Sous-Traitance] as Sous_traitance
from dbo.[societe$travaux]
where Région = 'SUD')
Select
max(Région) as Région,
Agence,
Ing,
count(Nb_Devis) as Nb_Devis,
count(Nb_Affaires) as Nb_Affaires,
count(Nb_Devis)/count(Nb_Affaires) as taux_Reussite,
sum(Montant) as Montant,
sum(Sous_traitance) as Sous_traitance
from test
where date between '01/01/2010' and '31/12/2010'
group by Agence,Ing
order by Agence |
Partager