'SQL Big Query - Add new column to table with query results?

I'd like to take two columns (latitude and longitude) and create a single column with the combined information. The final goal is (a) see if I can gather useful information about these locations and (b) create a map visualization with all of these coordinates.

I've successfully queried and gotten the combined latitude/longitude information with this query -

SELECT CONCAT(lat, lng) AS lat_lng FROM dataset.abc.xyz

And created a new column

ALTER TABLE dataset.abc.xyz ADD COLUMN latlng

But I can't figure out how to get the information from the query into the new column. Or is there a different process entirely that I should be doing?



Solution 1:[1]

Use an update:

UPDATE dataset.abc.xyz
SET latlng = CONCAT(CAST(lat AS STRING), CAST(lng AS STRING))
WHERE lat IS NOT NULL;

But note that this column may actually not be necessary since it can easily be computed from the latitude and longitude columns. So, you might find that not adding this column can also work for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1