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
 General SQL Server Forums
 New to SQL Server Programming
 Adding 2 columns from one table to another table

Author  Topic 

Priyamvada
Starting Member

1 Post

Posted - 2012-01-08 : 01:15:52
I am working on an asp.net application
I want to add the sum of 2 columns from same table to third column in different table.
Eg: Student_Total=Student_history+Student_geography.
Student_history and Student_geography represent marks in respective subjects i want to add marks from these subjects in table Student_Marks to Sum_Total column in table named as Results.

How to go about it.

Grateful if you would help me

priya

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-08 : 02:23:55
[code]
UPDATE t
t.Sum_Total = t1.Student_Total
FROM Student_marks t
CROSS APPLY (SELECT Student_history + Student_geography AS Student_Total
FROM Student
WHERE Student_ID = t.Student_ID
)t1
[/code]

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

Go to Top of Page
   

- Advertisement -