In my case I had used it in a lot of places the first example if you have 2 values for a select statement like gender (Male or Female) then use the following statement:
SELECT CASE Gender WHEN 'Male' THEN 1 ELSE 2 END AS Gender
If there is more numerous than one condition alike nationalities you could also use it as the below statement:
SELECT CASE Nationality
WHEN 'AMERICAN' THEN 1
WHEN 'BRITISH' THEN 2
WHEN 'GERMAN' THEN 3
WHEN 'EGYPT' THEN 4
WHEN 'PALESTINE' THEN 5
ELSE 6 END AS Nationality
If you want to learn more about SQL, Check out this SQL Certification by Intellipaat.
For more information visit :