Hi all...
I have a datatable as follows -
| SrNo | Location | Total | Pending(A) | New(B) | Updated(C) | Remarks |
| 1 | Assam | 4 | 1 | 3 | 5 | Test |
| 2 | Bihar | 7 | 2 | 4 | 6 | Test |
| SrNo | Location | Total | A | B | C | D=A+B-C | Remarks |
| 1+3-5=-1 | |||||||
| 2+4-6=0 |
Total of Columns - Total, A, B,C,D.
Please guide...

Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 16, 2015, 4:33 AM EDT
select *,(Pending+New-updated) as Total from @test
Riddhi ValechaRank #794 · 2.9K reputationPosted Jun 16, 2015, 5:15 AM EDT
Bhushan BhasmeRank #2,348 · 604 reputationPosted Jun 16, 2015, 6:37 AM EDT
foreach (DataRow dtRow in dtTable.Rows) { dtrow["D"]=(Convert.ToInt32(dtrow["A"])+Convert.ToInt32(dtRow["b"])+Convert.Toint32(dtRow["c"])).Tostring(); } Here You Will GEt all column addition in d column int a=0; foreach(DataColumn dc in dtTable.Columns) { a= convert.Toint32(dc["D"])+a; } In a You Will Get columnwise Addition Hope this Will help You