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
|
select
am0.titulaire, am0.var5,
hi0.status, count(*)
from
SYSADM.hi0 hi0, SYSADM.hi3 hi3, SYSADM.am0 am0, SYSADM.hi00
where
am0.titulaire = hi3.personne
and
hi0.ref = hi00.code
and
hi3.hi0_nrid = hi0.nrid
and
hi0.ref like '%FUP%'
and
am0.titulaire like '%'
and
CASE (hi0.status) WHEN 'To do' THEN hi0.date_deb>=DATEADD(month,-12,getdate())
ELSE hi0.faitle>=DATEADD(month,-12,getdate())
and
CASE (hi0.status) WHEN 'To do' THEN hi0.date_deb<=getdate()
ELSE hi0.faitle<=getdate()
and
am0.template is null and hi0.template is null
group by am0.titulaire, am0.var5, hi0.status |