amazon-redshift - 在 Redshift 中用一个结果列选择不同的多列
问题描述
我想在 Redshift 下面执行。它可以在 Postgrsql 中使用 unnest 处理,但不能在 Redshift 中工作
其实我有像
id col_a col_b col_c
1 ABD CDE XYZ
2 CDE null null
3 ABD null null
3 FGH LMN null
我期望结果
ABC
ABD
CDE
FGH
LMN
XYZ
解决方案
对于UNION
每一列,获取不同的值:
select col_a as col from tablename
where col_a is not null
union
select col_b from tablename
where col_b is not null
union
select col_c from tablename
where col_c is not null
order by col
推荐阅读
- html - 获取动态填充下拉列表的旧选定值
- java - 如何生成唯一值数组
- javascript - 尝试使用 pkg 制作 Typescript + NodeJS 应用程序的二进制文件时出现错误“无法读取文件,ENOENT node:util”
- reactjs - 防止在特定 RTK 查询端点上缓存
- java - 当使用 Saxon 的 XSLT 引擎处理 XML 时,如何将我的 XSL 文件指向它需要的 XSD 文件?
- excel - 创建循环以循环工作表
- r - Add a comma after two digits in R?
- merge - 如何使用 SAS 中的 prosql 与 2 个以上的表进行行绑定
- sql - 非附加措施
- sql - 在满足条件的组中重复结果 Big Query