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 |
|
vnsbabu
Starting Member
1 Post |
Posted - 2007-06-25 : 01:08:01
|
| how to subtract values from column to anotherch.. |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-25 : 01:12:59
|
| Do u mean creating a computed column by subtracting a column from another column?give some sample data...--------------------------------------------------S.Ahamed |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-25 : 03:32:52
|
quote: Originally posted by vnsbabu how to subtract values from column to anotherch..
Select col1, col2, col1-col2 as new_col from tableYou need to Learn SQLMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-25 : 03:34:26
|
| Also you need to handle NULLMadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
|
|
noorahmed.shaik
Starting Member
11 Posts |
Posted - 2007-06-25 : 11:12:08
|
quote: Originally posted by vnsbabu how to subtract values from column to anotherch..
MEANS TO SAY COMPUTED COLUMNSNoor AhmedKeysoft solution |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-06-25 : 11:18:28
|
| A computed column is computed from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, variable, and any combination of these connected by one or more operators. The expression cannot be a subquery. For example, in the AdventureWorks sample database, the TotalDue column of the Sales.SalesOrderHeader table has the definition: TotalDue AS Subtotal + TaxAmt + Freight. Something like ALTER TABLE Table1 ADD ColNew AS (Col1 + Col2 - Col3)Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|