Hive相关

--把多商品订单的支付金额拿出来
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

hive实现group_concat

 

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值