CASE is used to evaluate several conditions and returns one of multiple possible result.
SELECT *, IsActive = CASE Active WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE 'N/A' END FROM PersonalDetails
In above case, we are trying to get all column value of the PersonalDetails and adding another column named “IsActive” and
WHEN Active column value of the database table is 1 (true) then setting “IsActive” value to ‘Yes’,
WHEN 0 (false) then ‘No’
ELSE setting it to ‘N/A’.
Views: 2424 | Post Order: 103