How to calculate grade of student using tsql?
===

I have a scenario like this,

     Studentid|Subject1|Subject2|Subject3|Subject4|Subject5|Grade
  
       1      |   1    |    1   |   1    |   1    |    1   |
       2      |   1    |    2   |   2    |   2    |    3   |
       .....etc

 The table shows,student id and their rank in each sujects.I want to update grade column,based on the following condition,

1)if all subjects ranks are 1,then grads should be A
2)if any 3 ranks are 1,and other 2 subjects are having rank as 2, then B
3)if any 3 ranks are 2,and other 2 subjects are having rank as 3, then c
etc

Is it possible to write single query?

         