select *
,(select sum(Budget)
from b
where Position = a.Position
and a.Name = (select max(name) from a c where Position = a.Position)
)
from A
,(select sum(Budget)
from b
where Position = a.Position
and a.Name = (select max(name) from a c where Position = a.Position)
)
from A
,isnull((select sum(Budget)
from b
where Position = a.Position
and a.Name = (select top 1 name
from a c
where Position = a.Position
order by name),0)
)
from A
select *
,isnull((select sum(Budget)
from b
where Position = a.Position
and a.Name = (select max(name) from a c where Position = a.Position)
),0)
from A