[Solved] PostgreSQL query to split based on Strings & Concatenate them into new individual columns


Use string_to_array to split the string into multiple elements that can be accessed individually:

select rules[1] as rule_1, 
       rules[2] as rule_2,
       rules[3] as rule_3,
       rules[4] as rule_4,
       rules[5] as rule_5,
       rules[6] as rule_6
from (
  select string_to_array(rules, '|') as rules
  from rulebook
) t

1

solved PostgreSQL query to split based on Strings & Concatenate them into new individual columns