按不同名称及其值总和对数据进行分组

Group data by distinct names with their values sum

我在 google 表中有下一种格式的数据(多对列):

Source: | Value: | Source: | Value: | ...
Name1     100    |  Name1     20
Name2     50     |  Name2     60
Name1    -10     |  Name3     600
Name3    -150    |  Name2     -700
Name1     500    |  Name2     50
...

如何按名称和总值对其进行分组? 我需要实现这个:

uniq(Source): | sum(Value):
Name1           1000
Name2           1400
Name3           -100
...
=QUERY({A2:B; C2:D}, 
 "select Col1,sum(Col2) 
  where Col1 is not null 
  group by Col1 
  label sum(Col2)''")