select
SUPER_SITE_ID,
split(tmp.cmapaign,',')[0] as SUPER_CMAPAIGN_ID ,
split(tmp.cmapaign,',')[2] as SUPER_POSITION
from (
select
SUPER_SITE_ID ,
cmapaign
from cjfImprLog lateral view explode(split(super_cmapaign,'\\;')) cmapaign1 as cmapaign
where yyyymmdd='${yyyymmdd}' and SUPER_TYPE =1 and super_cmapaign <> ''
SUPER_SITE_ID,
split(tmp.cmapaign,',')[0] as SUPER_CMAPAIGN_ID ,
split(tmp.cmapaign,',')[2] as SUPER_POSITION
from (
select
SUPER_SITE_ID ,
cmapaign
from cjfImprLog lateral view explode(split(super_cmapaign,'\\;')) cmapaign1 as cmapaign
where yyyymmdd='${yyyymmdd}' and SUPER_TYPE =1 and super_cmapaign <> ''
) tmp
红色部分必须要写,否则不会出现列转行的结果。
绿色部分要注意转义符号

本文介绍了一种使用SQL实现列转行的技术方案,通过具体的SQL语句示例展示了如何从复杂的数据结构中提取所需信息,并重点讲解了使用split函数进行字符串拆分的方法。
573

被折叠的 条评论
为什么被折叠?



