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 |
|
alexviseu
Starting Member
8 Posts |
Posted - 2006-06-30 : 05:23:39
|
| I need to create a new column where I subtract one column by another.I've been looking fo that for a while now, can someone explain how to do this? |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2006-06-30 : 05:28:56
|
| computed column:alter table t add c as(a-b)rockmoose |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-30 : 05:29:05
|
"I need to create a new column"Alter table table_name add column_name datatype"where I subtract one column by another."can you explain more in detail ? KH |
 |
|
|
alexviseu
Starting Member
8 Posts |
Posted - 2006-06-30 : 05:36:13
|
| The thing is that I don't want to mess with tables, i want to do it in the query.Does someone knows how to do that? |
 |
|
|
alexviseu
Starting Member
8 Posts |
Posted - 2006-06-30 : 05:38:37
|
| khtan:I've like:SELECT * FROM Table1 INNER JOIN Table2ON Table1.stuff=table1.stuffAnd I need to do something like:SELECT *,(Table1.number-Table2.number) as SubtractionFROM Table1 INNER JOIN Table2ON Table1.stuff=table1.stuff |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-30 : 05:46:25
|
OK. I see what you want. You have already got it in your 2nd query. KH |
 |
|
|
alexviseu
Starting Member
8 Posts |
Posted - 2006-06-30 : 06:04:29
|
| rotfl, it was suposed to be pseudo code. Made up at the moment.Thanks for the help. :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-30 : 07:00:49
|
| >>I need to create a new column where I subtract one column by another.No need to create New column. As is in your example use it in select query with proper column nameMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|