SCENARIO:
Table Employee_Details has Gender column. In this Gender column M should be updated with F and F should be updated with M.Employee_Details |
EXPECTED:
Employee_Details |
SOLUTIONS (Using DECODE):
We have to update table using DECODE function as follows.
UPDATE EMPLOYEE_DETAILS
SET GENDER=DECODE(GENDER,'M','F',
'F','M');
SOLUTIONS (USing CASE statement ):
We have to update table using CASE statement as follows.
SET GENDER= CASE WHEN Gender='M' THEN 'F'
WHEN Gender='F' THEN 'M'
END;
For Other Scenario based questions, please visit below URL:
http://itjunction4all.blogspot.com/2016/08/sql-scenario-based-questions-part-5.html
If you like this post, don't forget to share and post comment.
Thanks sunil..it was really helpful.
ReplyDeleteVery Useful syntax n queries
ReplyDelete