Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在Nifi中的组内应用条件_Sql_Apache Nifi - Fatal编程技术网

Sql 在Nifi中的组内应用条件

Sql 在Nifi中的组内应用条件,sql,apache-nifi,Sql,Apache 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并在查询记录处理器中使用having子句,但Nifi不支持having子句。您

如何获取只有未结订单的供应商列表?我的样本数据如下:

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并在查询记录处理器中使用having子句,但Nifi不支持having子句。您可以尝试以下操作

从表中选择不同的T.SupplierID作为T 不存在的地方 从表中选择1作为X,其中T.SupplierID=X.SupplierID 和X.orderStatus='closed' 使用不存在,并按如下方式分组:

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

工作!,谢谢