我有不同大小的数组,我希望数组中的每个值位于单独的行中。为此,我使用了交叉连接取消嵌套。但是它正在工作,它正在删除空数组。
因此,当我这样做时,我的列 ID 包含不同的数组,其中一些为空
select *
from table
cross join unnest (t.id) as t(order_id)
where length(order_id) = 5 or order_id is NULL
Run Code Online (Sandbox Code Playgroud)
我只得到以下结果
| ID | 订单号 |
|---|---|
| 23deo jfr32 6582w | 23deo |
| 23deo jfr32 6582w | 杰夫32 |
| 23deo jfr32 6582w | 6582瓦 |
而且我要
| ID | 订单号 |
|---|---|
| 23deo jfr32 6582w | 23deo |
| 23deo jfr32 6582w | 杰夫32 |
| 23deo jfr32 6582w | 6582瓦 |
| 无效的 | 无效的 |
如果有人知道如何取消嵌套空值,我们将不胜感激。我一直在互联网上查找,我发现我们可以包含一个WITH ORDINALITY 子句,但我不知道它是如何工作的。