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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Adding two rows in a column

Author  Topic 

Jocc
Starting Member

2 Posts

Posted - 2011-08-03 : 12:15:47
Hi , I am a newbie in Sql programming.

I would like to add two rows in a cloumn to get a value


For instance;
Qid, Qno, Answer
371, 35, 44
222, 38, 45

i need to add both answers to give me a value for another column.

thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-03 : 12:53:14
what do you mean by add? do you mean 44 + 45=89 as the result for another column. then probably what you need is a computed column.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Jocc
Starting Member

2 Posts

Posted - 2011-08-03 : 14:50:57
Yes I thats what i mean.how do i add the computed column.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-04 : 08:45:39
just add like example below

CREATE TABLE tablename
(
A int,
B int,
C AS A + B
)



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -