I have a table:

```
ColA | ColB
1 1
2 1
2 1
3 1
4 1
5 1
```

I would like to sum ColB only once where ColA = 2.

Essentially, I would like to sum the values of ColB as if the table looked like

```
ColA | ColB
1 1
2 1
3 1
4 1
5 1
```

So the sum of ColB should be 5 not 6

Any ideas on how I can do this?

This site got me close, but it doesn't add either of the ColB values for the rows where ColA = 2.

`A2`

= 1,`A3`

= 2, and`A4`

also = 2, what do you want to have happen if`B3`

≠`B4`

? (Or aretheall`B`

values equal to 1? If so, you’re talking about a count rather than a sum.) Do you guarantee that the`A`

values are sorted? – Scott Feb 5 '13 at 1:45