Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT DISTINCT m.MutFactuur, m1.topay, m2.paid
- FROM tblBH_Mutaties m
- CROSS apply (SELECT SUM(MutBedragEX+MutBTW) AS topay FROM tblBH_Mutaties WHERE 71 = Mut_Ab_ID AND MutFactuur=m.MutFactuur AND MutPartNr=1 AND mutsoort = 2) m1
- CROSS apply (SELECT SUM(MutRekenBedrag) AS paid FROM tblBH_Mutaties WHERE 71 = Mut_Ab_ID AND MutFactuur=m.MutFactuur AND MutPartNr=1 AND (mutsoort = 7 OR mutsoort = 3)) m2
- WHERE m1.topay <> m2.paid
- AND Mut_Ab_ID = 71
- ORDER BY mutfactuur
Advertisement
Add Comment
Please, Sign In to add comment