I need to write a Stored Procedure. I have a table with some data now I need to insert relevant data into another table according to some condition
Example:
Table 1
Name Class Math Physics English
Alok V 60 50 45
Bobby V 78 87 86
Chandini VI 56 76 56
Dolly VII 87 56 66
Based on this condition
Insert Values into Table2
If class =V
(Table2.Physics=Select sum(Table1.Physics) from Table1 where Class like ‘V’
Table2.Maths=0 and table2.English=0)
If class =VI
(Table2.Maths=Select sum(Table1.Maths) from Table1 where Class like ‘VI’
Table2.Physics=0 and table2.English=0)
If class =VI
(Table2.English =Select sum(Table1.English) from Table1 where Class like ‘VII’
Table2.Physics=0 and table2.Maths =0)
]
Table 2
Class Math Physics English
V 0 137 0
VI 56 0 0
VII 0 0 66
Kindly Help me out