How to retrieve 'y' and 'n' comma separated values as 'yes' or 'no' from a single column I have a table in a database with these columns

id     name    facility_Type
1      Taluka    y,n,n,y,n


Now I want to retrieve the comma separated values like this

id      name     Ambulance   ward  male_doctors  female_doctors  operation_theator
 1    Taluka      yes         no      no             yes              no
Some databases would support something like this (Oracle, MySQL, PostgreSQL, SQLite).

select T.id,
       T.name,
       case substr(T.facility_type, 1, 1) when 'y' then 'yes' else 'no' end as Ambulance,
       case substr(T.facility_type, 3, 1) when 'y' then 'yes' else 'no' end as ward,
       case substr(T.facility_type, 5, 1) when 'y' then 'yes' else 'no' end as male_doctors,
       case substr(T.facility_type, 7, 1) when 'y' then 'yes' else 'no' end as female_doctors,
       case substr(T.facility_type, 9, 1) when 'y' then 'yes' else 'no' end as operation_theator
from T;


If you are on SQL Server you need to type out substring.

select T.id,
       T.name,
       case substring(T.facility_type, 1, 1) when 'y' then 'yes' else 'no' end as Ambulance,
       case substring(T.facility_type, 3, 1) when 'y' then 'yes' else 'no' end as ward,
       case substring(T.facility_type, 5, 1) when 'y' then 'yes' else 'no' end as male_doctors,
       case substring(T.facility_type, 7, 1) when 'y' then 'yes' else 'no' end as female_doctors,
       case substring(T.facility_type, 9, 1) when 'y' then 'yes' else 'no' end as operation_theator
from T;