I need to concatenate two strings, year and Quarter, which are structured like so: Year|Q
2007|1
2008|2
2005|4
I have tried the following code:
update `Project.MACRO.Table`
set YearQuarter = CAST(year as string) + '_' + CAST(quarter as string)
where quarter is not null
it does not work as only INT64 + INT64; FLOAT64 + FLOAT64; NUMERIC + NUMERIC are supported signatures. I don't believe I can use group_concat as part of an update. Any suggestions?
You can use CONCAT() function as below
CONCAT(CAST(year as STRING),'_',CAST(quarter as STRING))
or you can use FORMAT() as below
FORMAT('%i_%i', year, quarter)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments