【发布时间】:2017-11-24 10:20:37
【问题描述】:
我曾参考之前的帖子将一列分成两列。看起来我所指的示例是 sql,与 Hive 相比可能有所不同。如何将下面的 orig_data 转换为结果数据?
orig_data
name location code
Andrew M NY 145-ABG
Paul C NY 1787-ATG
Kate M NY 3874-WV
results
name location ID per
Andrew M NY 145 ABG
Paul C NY 1787 ATG
Kate M NY 3874 WV
select
name, location,
left(code, charindex('-',code) as id, --not working
right(code, charindex('-',code) as per, --not working
from
orig_table;
【问题讨论】: