Answer: update tbl_EmployeeEdu set SGradeObt = case WHEN MarksGot >= 80 THEN 'Merit'
WHEN MarksGot >= 60 AND MarksGot < 80 THEN 'First Class'
WHEN MarksGot >= 50 AND MarksGot < 60 THEN 'Second Class'
WHEN MarksGot < 50 THEN 'Failure' END
In the above query I am using update statement with case when statements. Since I need to update all the column in table I didn't use where condition. Using Case When syntax of SQL Server I am assiging the conditions. When MarksGot >= 80 then I am setting the text "Merit" to sGradeObt column. Similarly for First class, Second class and failure conditions
Asked In: Many Interviews |
Alert Moderator