my question is
how to sum and auto-increment into other column when we insert into column 1
| id | Column1(Inserted) | column2(Auto-increment column) |
| 1 | 10 | 10 |
| 2 | 10 | 20 |
| 3 | 20 | 40 |
| 4 | 30 | 70 |
how to perform this and what is the query for this kind of result
| id | Column1(Inserted) | column2(Auto-increment column) |
| 1 | 10 | 10 |
| 2 | 10 | 20 |
| 3 | 20 | 40 |
| 4 | 30 | 70 |
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Midhun TpPosted Apr 3, 2017, 5:21 AM
SET @val=10
INSERT INTO tablename (col1, col2)
SELECT @val,isnull(sum(col1),0)+@val FROM tablename
Nitin SontakkePosted Apr 3, 2017, 3:41 AM
Manish KumarPosted Apr 3, 2017, 3:28 AM
Jitendra ShekhawatPosted Mar 30, 2017, 8:40 AM
Ramesh PalanivelPosted Mar 30, 2017, 8:18 AM