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
| select
t.SousFamille,
t.CAHT,
t.Taux_TVA,
from (
select
case
when t1.No_ between 061010 and 061010013 then UNITE1
when t1.No_ between 061020 and 061020019 then UNITE2
when t1.No_ between 061040 and 061040016 or t1.No_ = 069990001 then UNITE3
when t1.No_ between 071000 and 071000092 or t1.No_ = 051040001 then UNITE4
when t1.No_ between 071010 and 071010087 then UNITE5
when t1.No_ between 081000 and 081000011 then UNITE6
when t1.No_ between 091000 and 091000018 or t1.No_ = 069990000 then UNITE7
when t1.No_ = 101000000 then UNITE8
end as SousFamille,
cast((t1.[Amount]) as float) as CAHT,
cast(t1.[VAT %] as float) as Taux_TVA,
from dbo.[SOCIETE$Sales Invoice Line] as t1
inner join dbo.SOCIETE$Job as t2
on t1.[Job No_] = t2.[No_]
where t1.[Job No_] like '%AF.%'
and t1.[Amount] <> '0'
and t1.[Posting Date] between '01/01/2010' and '31/01/2010'
union all
select
case
when t1.No_ between 061010 and 061010013 then UNITE1
when t1.No_ between 061020 and 061020019 then UNITE2
when t1.No_ between 061040 and 061040016 or t1.No_ = 069991 then UNITE3
when t1.No_ between 071000 and 071000092 or t1.No_ = 051041 then UNITE4
when t1.No_ between 071010 and 071010087 then UNITE5
when t1.No_ between 081000 and 081000011 then UNITE6
when t1.No_ between 091000 and 091000018 or t1.No_ = 069990 then UNITE7
when t1.No_ = 101000000 then UNITE8
end as SousFamille,
cast(t1.Amount as float)*-1 as CAHT,
cast(t1.[VAT %] as float) as Taux_TVA,
from dbo.[SOCIETE$Sales Cr_Memo Line] as t1
inner join dbo.SOCIETE$Job as t2
on t1.[Job No_] = t2.[No_]
where t1.[Gen_ Prod_ Posting Group]='unites'
and t1.[Posting Date] between '01/01/2010' and '31/01/2010'
)t
order by Taux_TVA,Type_etude,SousFamille
having (t.SousFamille is not null) |