Union查询,怎么不返回为NULL的列?
1个回答
展开全部
with t as
(select 1 as id, 1 as a, null as b ,null as c, null as d , 1 as e from dual union all
select 2,null,null,1,1,1 from dual union all
select 3,1,null,null,null,null from dual union all
select 4,1,null,null,null,null from dual union all
select 5,null,1,null,null,null from dual)
select id,listagg(col,',')within group (order by col) as col from
(select id,col,value from t unpivot (value for col in (a,c,b,d,e)))
where value is not null
group by id
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询