[
{ id: 1, name: Москва },
{ id: 2, name: Минск },
{ id: 3, name: Берлин},
]
[
{ countyId: 1, value: 45 },
{ countyId: 1, value: 15 },
{ countyId: 2, value: 5 },
{ countyId: 2, value: 5 },
{ countyId: 2, value: 10 },
{ countyId: 3, value: 1 },
]
[
{ id: 1, name: Москва, value: 60 },
{ id: 2, name: Минск, value: 20 },
{ id: 3, name: Берлин, value: 1},
]
select t1.id, t1.name, sum(t2.value) as val from Table1 t1
join Table2 t2 on t1.id = t2.countyid
group by t1.id, t1.name
{ countyId: 2, value: 5 },
{ countyId: 2, value: 5 },