在 Nifi 的组内应用条件
Apply condition within a group in Nifi
如何获取只有未结订单的供应商列表?我的示例数据如下:
SuppierID, orderID, orderStatus,orderdate
1,11,open,12/28/2020
1,22,open,12/27/2020
2,33,open,12/26/2020
2,44,closed,12/27/2020
3,55,closed,12/26/2020
预期输出为:
1,12/28/2020
尝试使用 groupby 并在查询记录处理器中使用,但 Nifi 似乎不支持该子句
你可以试试
SELECT DISTINCT T.SupplierID 来自 YourTable AS T
不存在的地方
(
SELECT 1 来自 YourTable AS X WHERE T.SupplierID=X.SupplierID
和 X.orderStatus='closed'
)
使用not exists
和group by
如下:
Select t.supplier_id, 'open' as order_status, max(order_date) as order_date
From your_table t
Where not exists
(Select 1 from your_table tt
Where tt.supplier_id = t.supplier_id
And tt.order_status <> t.order_status)
And t.order_status = 'open'
Group by t.supplier_id
如何获取只有未结订单的供应商列表?我的示例数据如下:
SuppierID, orderID, orderStatus,orderdate
1,11,open,12/28/2020
1,22,open,12/27/2020
2,33,open,12/26/2020
2,44,closed,12/27/2020
3,55,closed,12/26/2020
预期输出为:
1,12/28/2020
尝试使用 groupby 并在查询记录处理器中使用,但 Nifi 似乎不支持该子句
你可以试试
SELECT DISTINCT T.SupplierID 来自 YourTable AS T 不存在的地方 ( SELECT 1 来自 YourTable AS X WHERE T.SupplierID=X.SupplierID 和 X.orderStatus='closed' )
使用not exists
和group by
如下:
Select t.supplier_id, 'open' as order_status, max(order_date) as order_date
From your_table t
Where not exists
(Select 1 from your_table tt
Where tt.supplier_id = t.supplier_id
And tt.order_status <> t.order_status)
And t.order_status = 'open'
Group by t.supplier_id