原表:
目标表:
sql代码:
select
dp as 日期
,city_name as 城市,
split_part(subject,‘:’,1) as 指标,
cast( split_part(subject,‘:’,2) as double ) as 数值
from(
select trans_array(2,‘;’,dp,city_name,subject) as (dp,city_name,subject)
from(
select dp,city_name,
concat(
‘总曝光pv’,‘:’,总曝光pv,‘;’,
‘总曝光uv’,‘:’,总曝光uv,‘;’,
‘商详pv’,‘:’,商详pv,‘;’,
‘商详uv’,‘:’, 商详uv ,‘;’
‘商机数’,‘:’, 商机数 ,‘;’
‘付费商机数’,‘:’, 付费商机数 ,‘;’
‘商机成本’,‘:’, 商机成本 ,‘;’
‘二轮私信用户数’,‘:’, 二轮私信用户数 ,‘;’
‘支付订单数_含退款’,‘:’, 支付订单数_含退款 ,‘;’
‘支付gmv_含退款’,‘:’, 支付gmv_含退款
) as subject
from ttb)tt
)tx
;