I have a table
StudentID StudentName Subject Marks
1 Savita EC1 50
1 Savita EC2 55
1 Savita EC3 45
1 Savita EC4 34
1 Savita EC5 23
2 Rajesh EC1 34
2 Rajesh EC2 56
2 Rajesh EC3 12
2 Rajesh EC4 45
2 Rajesh EC5 23
3 Smita EC1 76
3 Smita EC2 45
3 Smita EC3 67
3 Smita EC4 56
3 Smita EC5 76
4 Rahul EC1 66
4 Rahul EC2 34
4 Rahul EC3 22
4 Rahul EC4 18
4 Rahul EC5 33
I wrote a query like
SELECT StudentName, EC1,EC2,EC3,EC4,EC5,TotalMarks, case
when EC1<30 and ec2<30 then 'fail'
when EC1<30 and EC3<30 then 'fail'
when EC1<30 and EC4<30 then 'fail'
when EC1<30 and EC5<30 then 'fail'
when EC2<30 and EC3<30 then 'fail'
when EC2<30 and EC4<30 then 'fail'
when EC2<30 and EC5<30 then 'fail'
when EC3<30 and EC4<30 then 'fail'
when EC3<30 and EC5<30 then 'fail'
when EC4<30 and EC5<30 then 'fail'
else 'pass'
end as Result
FROM (SELECT StudentName, EC1, EC2, EC3, EC4, EC5, TotalMarks=EC1+EC2+EC3+EC4+EC5
FROM Student
PIVOT(sum(Marks) for subject in([EC1],[EC2],[EC3],[EC4],[EC5],[TotalMarks]))as pivotTable) A
Which gives an output of students who have less than 30 marks in 2 subjects as fail or else pass
Rahul 66 34 22 18 33 173 fail
Rajesh 34 56 12 45 23 170 fail
Savita 50 55 45 34 23 207 pass
Smita 76 45 67 56 76 320 pass
I want to add 7 marks to each subject which is less than 30 and see the pass fail students after adding 7 marks. eg-After adding 7 marks rajesh record should be like
Rajesh 34 56 19 45 30 170 pass