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 |
|
haekz008
Starting Member
10 Posts |
Posted - 2012-01-24 : 03:55:24
|
| i am searching for a query that can add the value of the two attributes,.,for example, i have a 3 attributes which is the total payment, partial payment and last payment,.,how am i going to get the value of the partial and last payment and insert it on the total payment?help me pls,.,thankyouhaekz008 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-01-24 : 04:33:35
|
| Read about "Compute Column" in Books online..Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-01-24 : 04:50:52
|
quote: Originally posted by senthil_nagore Read about "Computed Column" in Books online..Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-24 : 05:04:20
|
| Not sure if that actually fits your requirement.Did you mean that you need to calculate some sort of running total from each row to the next? If so post some sample data and the required output.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
haekz008
Starting Member
10 Posts |
Posted - 2012-01-24 : 05:19:50
|
| At charlie-->here is the examplepartial payment-----Last payment------total payment-------5-----------------5------------------10by the way thanks for the help of others,., haekz008 |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-01-24 : 05:47:00
|
if you already have partial payment and last payment in the table then all you need is a computed column (as the others said)Something likeBEGIN TRANCREATE TABLE #foo ( [val1] INT , [val2] INT ) ALTER TABLE #foo ADD [computedCol1] AS [val1] + [val2] PERSISTEDINSERT #foo ([val1], [val2])VALUES (1,1), (1,2), (2,2)SELECT * FROM #fooROLLBACK Results:val1 val2 computedCol1----------- ----------- ------------1 1 21 2 32 2 4 Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
haekz008
Starting Member
10 Posts |
Posted - 2012-01-24 : 06:20:18
|
| thank yo very much for your help,.,it really helps :)haekz008 |
 |
|
|
|
|
|
|
|