详情页标题前

Flink这样子的行转列的数据 我一条id为445的过来 但是其余的字段 不想变成空 有什么办法吗?-云小二-阿里云

详情页1

Flink这样子的行转列的数据 我一条id为445的过来 但是其余的字段 不想变成空 有什么办法吗 ?除了每个字段分开写入 ,STRING_AGG(distinct case when t3.id = 413 then t2.name end )
,STRING_AGG(distinct case when t3.id = 418 then t2.name end )
,STRING_AGG(distinct case when t3.id = 421 then t2.name end )
,STRING_AGG(distinct case when t3.id = 423 then t2.name end )
,STRING_AGG(distinct case when t3.id = 425 then t2.name end )
,STRING_AGG(distinct case when t3.id = 428 then t2.name end )
,STRING_AGG(distinct case when t3.id = 438 then t2.name end )
,STRING_AGG(distinct case when t3.id = 440 then t2.name end )
,STRING_AGG(distinct case when t3.id = 443 then t2.name end )
,STRING_AGG(distinct case when t3.id = 445 then t2.name end )

以下为热心网友提供的参考意见

你可以使用coalesce函数将空值替换为其他值,例如空字符串。这样,当某个字段没有匹配到时,它将被替换为空字符串,而不是NULL。以下是修改后的代码:

,STRING_AGG(distinct coalesce(case when t3.id = 413 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 418 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 421 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 423 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 425 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 428 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 438 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 440 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 443 then t2.name end, ''))
,STRING_AGG(distinct coalesce(case when t3.id = 445 then t2.name end, ''))

这样,当某个字段没有匹配到时,它将被替换为空字符串,而不是NULL。

转转请注明出处:https://www.yunxiaoer.com/180445.html

(0)
上一篇 2024年1月4日
下一篇 2024年1月4日
详情页2

相关推荐

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
本站为广大会员提供阿里云、腾讯云、华为云、百度云等一线大厂的购买,续费优惠,保证底价,买贵退差。