[英]bigquery command to split a column by position in
How do I split a column by position in bigquery如何在bigquery中按位置拆分列
Here I have a column with date of birth like this在这里我有一个像这样的出生日期的专栏
19900311
20071103
19930802
19840130
19790206
19940301
I need to get only the year, so need to use substring function to get positions from 0,4
我只需要得到年份,所以需要使用substring 函数从0,4
获取位置
Could someone please help me with the correct command有人可以用正确的命令帮助我吗
Below is for BigQuery Standard SQL以下是 BigQuery 标准 SQL
You can use SUBSTR function as in below example您可以使用 SUBSTR 函数,如下例所示
#standardSQL
WITH `project.dataset.table` AS (
SELECT '19900311' date_of_birth UNION ALL
SELECT '20071103' UNION ALL
SELECT '19930802' UNION ALL
SELECT '19840130' UNION ALL
SELECT '19790206' UNION ALL
SELECT '19940301'
)
SELECT date_of_birth, SUBSTR(date_of_birth, 1, 4) year_of_birth
FROM `project.dataset.table`
with result结果
Row date_of_birth year_of_birth
1 19900311 1990
2 20071103 2007
3 19930802 1993
4 19840130 1984
5 19790206 1979
6 19940301 1994
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.