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 |
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-11-15 : 16:55:08
|
Hi,I have a table with two columns and am trying to create a formula in Column 1 , row 2 that will sum up Column 1 row 1 and Column 2 row 2. I want to continue the same formula down the column so that each row adds the row above it to the row next to it. How can i achieve this? what function?Thanks much for your help! |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-16 : 00:45:48
|
You want to store the calculated value in a column.One problem with this approach is that incase a middle row is deleted, it may not update the data for computed column in subsequent rows unless you write a trigger.If possible you do the calculation before presenting the data to user.What version of SQL you are using ? |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-16 : 03:20:18
|
Instead you can do it via SELECT statementMadhivananFailing to plan is Planning to fail |
 |
|
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-11-16 : 10:10:08
|
I am using Sql server 2005. can you please advise on the exact functions that you suggest to use? I am very unclear on how to approach this problem. thanks! |
 |
|
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-11-19 : 19:32:51
|
quote: Originally posted by madhivanan Instead you can do it via SELECT statementMadhivananFailing to plan is Planning to fail
Can you please specify how exactly I do this with select statement? thanks! |
 |
|
namman
Constraint Violating Yak Guru
285 Posts |
Posted - 2010-11-21 : 01:54:13
|
I think I misunderstand your question .... It is a bit unclear ... |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-26 : 09:31:59
|
Post some sample data with expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|