特殊数据类型的处理-- 不同手机品牌的用户数--

extra1(string):{"systemtype":"ios","education":"master","marriage_status":"1","phonebrand":"iphone X"}extra2(map<string,string>)

{"systemtype":"ios","education":"master","marriage_status":"1","phonebrand":"iphone X"}

-- 不同手机品牌的用户数--

第一种情况

SELECT get_json_object(extra1,'$.phonebrand') as phone_brand,
count(distinct user_id) user_num
FROM user_info
GROUP BY get_json_object(extra,'$.phonebrand');

第二种情况

SELECT extra2['phonebrand'] as phone_brand,
count(distinct user_id) user_num
FROM user_info
GROUP BY extra2['phonebrand'];

get_json_object(stringjson_string,string path)param 1 :需要解析的json字段,如 get_json_object(extra1,'$.phonebrand')
parma 2:用.key取出想要获取的value,如 extra2['phonebrand']

posted @ 2024-06-14 16:14  帆帆代码院  阅读(2)  评论(0编辑  收藏  举报