【发布时间】:2021-07-28 00:44:55
【问题描述】:
我有不同大小的数组,我希望数组中的每个值都位于不同的行中。 为此,我使用了交叉连接 unnest。但是它正在工作,它正在删除空数组。
所以,当我这样做时,我的列 ID 包含不同的数组,有些是空值
select *
from table
cross join unnest (t.id) as t(order_id)
where length(order_id) = 5 or order_id is NULL
我只得到以下结果
| ID | order_id |
|---|---|
| 23deo jfr32 6582w | 23deo |
| 23deo jfr32 6582w | jfr32 |
| 23deo jfr32 6582w | 6582w |
我想要
| ID | order_id |
|---|---|
| 23deo jfr32 6582w | 23deo |
| 23deo jfr32 6582w | jfr32 |
| 23deo jfr32 6582w | 6582w |
| null | null |
如果有人知道如何取消嵌套空值,将不胜感激。我一直在网上寻找,我看到我们可以包含一个 WITH ORDINALITY 子句,但我不知道它是如何工作的。
【问题讨论】:
标签: sql null presto unnest trino