我试图计算超过30分钟的传输次数,并且此错误不断出现

问题描述 投票:0回答:2

这是我写的公式↓

count(if(avg(timestamp_diff(broker_delivery_date,request_datetime,minute)),0) >= 30,id,NULL)

这是不断出现的错误↓

对于参数类型为FLOAT64,INT64。支持的签名:IF(BOOL,ANY,ANY)在[10:10]

sql google-bigquery
2个回答
0
投票

假设您的问题是“为什么会这样?”]]

IF(BOOL, ANY, ANY)

需要三个参数。您只给它两个。它是这样处理的:

count(if(
         avg(timestamp_diff(broker_delivery_date,request_datetime,minute)),  <-- This is not a BOOL
         0  <-- This is the second parameter to if
         ) >= 30,  <-- This is a BOOL as the first parameter to count
      id,  <-- This is a second parameter to count
      NULL) <-- This is the third parameter to count

尝试一下(免责声明:未测试):

count(if(avg(timestamp_diff(broker_delivery_date,request_datetime,minute)) >= 30,
         1,
         NULL)
      )

0
投票

IF语句需要一个boolean表达式。您在错误的位置关闭了括号,如下所示,这导致IF参数为FLOAT(AVG结果)而不是表达式AVG(...) >= 30如您所料。

© www.soinside.com 2019 - 2024. All rights reserved.