Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention. Check out this how-to article for more information.
declare @memberId varchar(11), @retireeId varchar(11), @retireePension money, @SURpensionTotal money set @memberId = '048011' select @retireeId = m.retireeId, @retireePension = r.retireePension from members m join (select e.memberId, sum(e.amount) retireePension from memberEarnings e join earningCodes c on c.earningCode = e.earningCode and e.earningCode in ('DRP','PEN') where e.enabled = 1 and e.oneShot = 0 group by e.memberId) r on r.memberId = m.retireeId where m.memberId = @memberId select m.retireeId,@SURpensionTotal = sum(e.amount) from members m join memberEarnings e on e.memberId = m.memberId and e.enabled = 1 and e.oneShot = 0 and e.earningCode in ('DRP','PEN') where (m.terminationDate is null or (dbo.firstOfThisMonth(default) <= m.terminationDate and dbo.firstOfNextMonth(default) > m.terminationDate)) and m.retireeId = @retireeId group by m.retireeId
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.