--把多商品订单的支付金额拿出来
select
explode(collect_set(split(split(payment,'":"')[1],'"')[0]))
from (
select
payment
from aaa.bbbbbb
lateral view
explode(
split(get_json_object(
jdp_response
,"$.trade_fullinfo_get_response.trade.orders.order"),'payment')
) adTable as payment
WHERE pt = 20200000
AND tid = '11111111'
)
用符号分隔+拼接查询结果到同一行
SELECT name
,concat_ws('|', collect_set(remark))
FROM (
SELECT name,remark
FROM student
)
GROUP BY name
;
--解析json里的子json
SELECT b.traceid
,b.fusion
,b.param
,b.uri
FROM (
SELECT explode(
split(
regexp_replace(
regexp_replace(
SUBSTRING(actions,1,length(actions)-1) --删掉最后一个]
,'\\[{'
,concat('{\"traceid\":\"',traceid,'\",') --拼接traceid做关联
)
,'},{'
,concat('}split_sign{\"traceid\":\"',traceid,'\",') --拼接traceid做关联
)
,'split_sign'--自己设置的分隔符
)
) AS DATA
FROM aaa
WHERE pt = ${bizdate}
) a
LATERAL VIEW json_tuple(a.DATA,'traceid','fusion','param','uri') b AS traceid,fusion,param,URI
SELECT
a.brand,
COUNT(1) brand_count,
concat_ws('|', collect_set(device)) device_brands,
sysdate(- 1) dt
FROM
(
SELECT
xxx_xxx [ 'brand' ] brand,
xxx2 device
FROM
xx.xxx_log
WHERE
dt = sysdate(- 1)
AND xx_id = 'xx2018_5131032'
) a
GROUP BY
a.brand