I have a table with column c_name, c_services which got values like this:
c_name | c_services
---------------------------------------
A | Email,Photos,Phone,Text
B | Phone,Text
C | Email,Photos
D | Photos,Phone
From above table and column (c_services), I am trying to populate data in 5 more columns which are:-
1. Total_Services - based on number of services ex- 4 for c_name 'A'
2. Email - 1 if service present else 0
3. Photos - 1 if service present else 0
4. Phone - 1 if service present else 0
5. Text - 1 if service present else 0
For the new column 'Total_Services', I tried:
array_length(regexp_split_to_table(c_services, ','), 1) Total_Services
or
count(regexp_split_to_table(c_services)) Total_Service
or
count(string_split(c_services)) Total_Service
but it is not working. For other column, I am thinking of using a case when to populate 1 or 0 value. Please help.