Reputation: 805
I have this
id value
-----!-----
1 3
2 3
1 2
1 1
i have tried using
SELECT id,sum(value) FROM table GROUP BY id
but it shows something different.
id ! value
--------------
1 6
2 3
And i want to add values based on their id's but keeping id's there
id ! value
--------------
1 6
2 3
1 6
1 6
Please help Thank you
Upvotes: 1
Views: 2337
Reputation: 7986
The naive approach would be :
select id, (select sum(value) from tbl where id = t1.id) value
from tbl t1
Upvotes: 1