Search code examples
sqldatabasegoogle-bigqueryreport

How to split a "full name" column into a separate first and last name column in Google Big Query?


I have a table with a column, full_name that has the full names formatted like this, with no spaces but a comma between:

Johnson,Boe

How do I query a separation between the two in the simplest way in Google Big Query?


Solution

  • If you want to split the name, you can use split():

    split(full_name, ',')[ordinal(1)] as last_name, split(full_name, ',')[ordinal(2)] as first_name