gpt4 book ai didi

apache - 大数据 hive 查询

转载 作者:可可西里 更新时间:2023-11-01 16:24:43 26 4
gpt4 key购买 nike

我有以下数据

Policy_Name  IssueYear   ExpiryYear
A 2001 2003
B 2003 2006

我需要如下输出:

Policy_Name ActiveYear
A 2001
A 2002
A 2003
B 2003
B 2004
B 2005
B 2006

最佳答案

select  t.Policy_Name 
,t.IssueYear + pe.i as ActiveYear

from mytable t
lateral view posexplode (split (space (ExpiryYear - IssueYear),' ')) pe as i,x
;

+---------------+------------+
| t.policy_name | activeyear |
+---------------+------------+
| A | 2001 |
| A | 2002 |
| A | 2003 |
| B | 2003 |
| B | 2004 |
| B | 2005 |
| B | 2006 |
+---------------+------------+

关于apache - 大数据 hive 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42886585/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com