Sora
Sora

Reputation: 142

How would I get the sum of a column where another column is equal to a specific value?

If I had something like the table below on a sqlite DB, would it be possible to get he sum of xp of ID 1, 2 ... etc?

ID  | XP
1     10  
1     47
1     3
1     1
2     48
4     39
5     22
5     48

example

1 = 61
2 = 48
4 = 39
5 = 60

Upvotes: 0

Views: 79

Answers (1)

rudolfovic
rudolfovic

Reputation: 3276

Yes, just execute select ID, sum(XP) from data group by ID

Upvotes: 2

Related Questions