anushya anu
anushya anu

Reputation: 21

Convert array ['a','b'] to string ('a','b') in bigquery

I need to convert ['a','b'] as ('a','b') in single line

I tried below one

with item as ( select ['a','b'] as list )

select array_to_string(list,''',''') from item

Am getting

Output : a,b

Expected : a','b

Upvotes: 1

Views: 147

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173038

Consider below

with item as ( 
  select ['a','b'] as list 
)
select "('" || array_to_string(list, "','") || "')"
from item             

with output

enter image description here

Upvotes: 2

Related Questions