这就是我写的↓公式
count(if(avg(timestamp_diff(broker_delivery_date,request_datetime,minute)),0) >= 30,id,NULL)这就是不断显示↓的错误
不匹配参数类型的函数IF签名: FLOAT64,INT64。支持签名:如果(BOOL,任何,任何)在10:10
发布于 2020-02-04 12:11:13
这个构造有几个问题。
首先,什么是,0)。这没有意义。也许你打算:
count(if(avg(timestamp_diff(broker_delivery_date, request_datetime, minute
)
) >= 30,
id, -- then
NULL -- else
)更重要的是,您正在嵌套聚合函数,这是不允许的。一种可能是,您根本不打算使用avg(),而只想查看单个行中的值。这也可以通过使用countif()进行简化
countif(timestamp_diff(broker_delivery_date, request_datetime, minute
) >= 30
)我猜这是你真正想要的。
发布于 2020-02-04 09:46:08
假设你的问题是“为什么会这样?”:
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)
)发布于 2020-02-04 10:30:24
IF语句需要一个boolean expression.You将括号关闭在错误的位置,如下所示,它导致IF参数是FLOAT (AVG结果),而不是您预期的AVG(...) >= 30表达式。
count(
if(
avg(
timestamp_diff(broker_delivery_date,request_datetime,minute)
)
,0
) >= 30,id,NULL)你可能想做的是:
count(
if(
avg(timestamp_diff(broker_delivery_date,request_datetime,minute)) >= 30
,id,NULL
)
)https://stackoverflow.com/questions/60053875
复制相似问题