Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
khalid.mushtaq
Starting Member
2 Posts |
Posted - 2008-12-03 : 01:07:25
|
| I actually want to know how to sum up data row wise and insert it into the same table.eg Name|BASIC|Hra|TA|Totalasd |2300 |200|20|NULLzxc |2200 |100}30|NULLI want sum of all rows which should be stored in "Total" columnThanks in advance |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-12-03 : 01:17:10
|
| select BASIC+Hra+TA from yourtable |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-03 : 01:20:22
|
| if columns are nullable use COALESCE(col,0) instead of simply col |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-03 : 01:51:38
|
| [code]UPDATE TableSET Total=COALESCE(BASIC,0)+COALESCE(Hra,0)+COALESCE(TA ,0)[/code] |
 |
|
|
|
|
|