我有一列称为desc,它包含以下字符串:
BUY 20 SAVE 5
所需的输出:20
我尝试过:
SELECT
desc,
split (desc, 'Y\\s')[1] as Revenue
FROM table1;
使用Hive regexp_extract(string subject, string pattern, int index)
功能:
regexp_extract(string subject, string pattern, int index)
请参见以下示例:
SELECT regexp_extract(desc, '.*? (\\d+) .*$', 1) AS Revenue
FROM table1
”