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 |
|
marileng
Starting Member
28 Posts |
Posted - 2002-03-19 : 23:41:31
|
| here is my code select a=1+1, b = a+2here is I want the result would be:a b2 4How can I use the |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-03-20 : 00:36:13
|
| your question isnt complete.thought you are looking for something like thisdeclare @a intdeclare @b intselect @a=0,@b=0select @a=@a+2select @b=@b+3select @a,@b--------------------------------------------------------------Edited by - Nazim on 03/20/2002 00:41:06 |
 |
|
|
marileng
Starting Member
28 Posts |
Posted - 2002-03-20 : 01:12:45
|
| This is my query Select a =(select table2.balance from table2 where table2.col1=table.col1),balance,b = balance + a from tablea balance b1 1 22 2 43 3 6.... 8 8 16 |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-03-20 : 05:10:52
|
Move the table2 select into the main query:SELECT a = table2.balance, table.balance, b = table.balance + table2.balanceFROM tableLEFT JOIN table2 ON table2.col1 = table.col1 If table2.col1 is not nullable, the join can be an INNER JOIN.Edited by - Arnold Fribble on 03/20/2002 05:12:52 |
 |
|
|
|
|
|