如何删除BQSQL中括号内的所有内容?

如何删除BQSQL中括号内的所有内容?,sql,google-bigquery,Sql,Google Bigquery,我试图实现的是,我有一个列,它是一个包含括号的字符串,我希望在查询结果时完全删除括号,例如: 12345 | Test | Test 1 (12345) 34567 | Test | Test 2 (34567) 67899 | Test | Test 3 (67899) 我希望结果是: 12345 | Test | Test 1 34567 | Test | Test 2 67899 | Test | Test 3 我知道有一种方法可以做到这一点,我只是没有找到正确的查询来删除从括号到括号

我试图实现的是,我有一个列,它是一个包含括号的字符串,我希望在查询结果时完全删除括号,例如:

12345 | Test | Test 1 (12345)
34567 | Test | Test 2 (34567)
67899 | Test | Test 3 (67899)
我希望结果是:

12345 | Test | Test 1
34567 | Test | Test 2
67899 | Test | Test 3
我知道有一种方法可以做到这一点,我只是没有找到正确的查询来删除从括号到括号的所有内容。我可以删除
()
本身,但不能删除
()
中的数字,我认为有一种更简单的方法可以做到这一点,而不是因为它而进行复杂的查询

提前谢谢你

一个简单的方法是:

select replace(col3, concat(' (', col1, ')'), '')
当括号包含第一列时,这会特别删除括号

如果你想在第一次聚会之前得到一切:

select split(col3, ' (')[safe_ordinal(1)]
或:

考虑下面的例子

#standardSQL
with `project.dataset.table` as (
  select 12345 col1, 'Test' col2, 'Test 1 (12345)' col3 union all
  select 34567, 'Test', 'Test 2 (34567)' union all
  select 67899, 'Test', 'Test 3 (67899)' 
)
select col1, col2, 
  trim(regexp_replace(col3, r'\(.+\)', '')) col3
from `project.dataset.table`    
有输出


这太完美了!我完全忘记了
Split
函数,它非常适合我的需要。非常感谢。这也非常有效,谢谢!!
#standardSQL
with `project.dataset.table` as (
  select 12345 col1, 'Test' col2, 'Test 1 (12345)' col3 union all
  select 34567, 'Test', 'Test 2 (34567)' union all
  select 67899, 'Test', 'Test 3 (67899)' 
)
select col1, col2, 
  trim(regexp_replace(col3, r'\(.+\)', '')) col3
from `project.dataset.table`