1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| with v1 as
(select b.matric,sum(monsal) as montant
from hr.ZX00 a, hr.ZX8K b
where a.nudoss = b.nudoss
and a.perpai = b.perpai
and b.codrub in ('INE','INO')
and b.perpai in ('MT202001','MT202002')
group by b.matric),
v2 as
(select matcle,sum(montan) as montant
from hr.ZYSR a, hr.ZY00 b
where a.nudoss = b.nudoss
and a.codrub = 'RVS'
group by b.matcle
)
select v1.matric, v1.montant, v2.montant, v1.montant - v2.montant as ecart
from v1
join v2 on v1.matric = v2.matcle
where v1.montant <> v2.montant; |
Partager