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
|Dataset not reading table data||12||46|
|Sql Data via Excel--performance issues||2||55|
|Getting max record but maybe not use Group BY||2||15|
|Is it possible to replace huge Multiple Spaces with a single space in SQL Server||2||0|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
20 Experts available now in Live!