Please assist me in explaining how the coder created this great solution, I'll briefly explain the table:
select * from people
returns the value:
name
Anibal Dorothea Tromp IV
The challenge is solved in many ways, but one solution really amazed me:
select
substring(name, '^(.+)\s\S+\s\S+$') as name,
substring(name, '^.+\s(\S+)\s\S+$') as first_lastname,
substring(name, '^.+\s(\S+)$') as second_lastname
from people
returns the result:
name first_lastname second_lastname
Anibal Dorothea Tromp IV
the real table has many more rows, some with 1 first name, others with 2 first names. So the challenge was to separate the names with the first name (name) being a different length word and sometimes more than 1 word.
If I look at the documentation on substring, there is no mention of this method, please explain to me how his great solution works or point me in the direction of a site that explains some of the components of this solution.
Many thanks, Tim