Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Insert a new row in table where certain conditions exist

$
0
0

Hi all.

I am working on a database in Microsoft Sql 2008 r2 and im trying to insert a new row into a table where certain conditions exist it's similar to an update / insert  hence why im a little concerned on how im going to do this.

student_Cla STUDENTID A B C D Absent lat

404 GARS 0 1 2 3 1 1



For every row where "absent"=1 and late =1

I want to keep that orginal row, but insert a new row into the table and perform a computation on one column 

                  
student_Cla	STUDENT ID	A	B	C	D	Absent	lat
404	                 GARS         	6	1	1	1	1	     1

Final result

student_Cla	STUDENT ID	A	B	C	D	Absent	lat
404          	        GARS                 0     1      2	3	 1	        1
404	                 GARS         	6	1	1	1	1	     1

 I have no issues performing any manipulation that i may need, just wondering how to perform the update

(sum of a,b,c and D in a) Thank you for any help








Viewing all articles
Browse latest Browse all 23857

Trending Articles