Hive 蜂巢相当于LISTAGG
我在oracle中有一个这样的查询,但我需要一个与此对应的配置单元SQL。有人能告诉我下面的配置单元对应的是什么吗 组内的“[”| | listag(t3.measure_title“;”)(按t3.measure_title排序)| |]]所有的|度量值|说明。如何在配置单元中重写这些内容 我在Oracle中的查询是Hive 蜂巢相当于LISTAGG,hive,hiveql,Hive,Hiveql,我在oracle中有一个这样的查询,但我需要一个与此对应的配置单元SQL。有人能告诉我下面的配置单元对应的是什么吗 组内的“[”| | listag(t3.measure_title“;”)(按t3.measure_title排序)| |]]所有的|度量值|说明。如何在配置单元中重写这些内容 我在Oracle中的查询是 SELECT t1.member_id, t2.first_name, t2.date_of_birth_sk, '[' || LISTAGG(
SELECT
t1.member_id,
t2.first_name,
t2.date_of_birth_sk,
'[' || LISTAGG(t3.measure_title, ';') WITHIN GROUP (ORDER BY t3.measure_title) || ']' all_measure_desc
FROM qms_gic_lifecycle t1
INNER JOIN dim_member t2
on t1.member_id = t2.member_id
INNER JOIN dim_quality_measure t3
on t1.quality_measure_id = t3.quality_measure_id
GROUP BY
t1.member_id,
t2.first_name,
t2.date_of_birth_sk;
根据重复值的处理方式,您可以使用
collect\u list
或collect\u set
<代码>收集列表保留重复值,而收集集
消除重复值
输出将是一个值数组
SELECT
t1.member_id,
t2.first_name,
t2.date_of_birth_sk,
COLLECT_LIST(t3.measure_title) as all_measure_desc
FROM qms_gic_lifecycle t1
INNER JOIN dim_member t2
on t1.member_id = t2.member_id
INNER JOIN dim_quality_measure t3
on t1.quality_measure_id = t3.quality_measure_id
GROUP BY
t1.member_id,
t2.first_name,
t2.date_of_birth_sk;
根据重复值的处理方式,可以使用collect_list或collect_set。collect_list保留重复值,而collect_set消除重复值
输出将是一个值数组
SELECT
t1.member_id,
t2.first_name,
t2.date_of_birth_sk,
COLLECT_LIST(t3.measure_title) as all_measure_desc
FROM qms_gic_lifecycle t1
INNER JOIN dim_member t2
on t1.member_id = t2.member_id
INNER JOIN dim_quality_measure t3
on t1.quality_measure_id = t3.quality_measure_id
GROUP BY
t1.member_id,
t2.first_name,
t2.date_of_birth_sk;
您可以使用concat_ws(string SEP,array)函数将结果数组转换为字符串
concat_ws(',', COLLECT_LIST(t3.measure_title) ) as all_measure_desc
请提供更多关于您答案的详细信息,以帮助其他人理解。