代码报错syntax error at or near "BETWEEN",代码如下SELECT $__timeGroupAlias("my_time_field", '1h'), MAX(PARAMVALUE)FROM ( SELECT to_number(paramvalue,'99.99') as paramvalue, CAST(starttime AS timestamp) as "my_time_field" FROM s01mplc.r_eqp_rawdata WHERE line='S013CBIM01' AND $__timeFilter(CAST(starttime AS timestamp)) AND pt_insert_date=to_char(now(), 'YYYYMMDD') AND parameter like 'FilmDownTime0%' ORDER BY starttime DESC) AGROUP BY 1
时间: 2024-03-05 20:54:53 浏览: 108
根据您提供的查询语句,我发现在时间过滤器 `$__timeFilter(CAST(starttime AS timestamp))` 之后,您没有使用 `BETWEEN` 关键字来指定时间范围,导致该语句在 `MAX(PARAMVALUE)` 之前的部分缺少时间约束。
您可以尝试修改该查询语句,将时间范围指定为 `BETWEEN` 关键字之间的两个时间戳,例如:
```
SELECT $__timeGroupAlias("my_time_field", '1h'), MAX(PARAMVALUE) FROM (
SELECT to_number(paramvalue,'99.99') as paramvalue, CAST(starttime AS timestamp) as "my_time_field"
FROM s01mplc.r_eqp_rawdata
WHERE line='S013CBIM01'
AND CAST(starttime AS timestamp) BETWEEN $__timeFrom() AND $__timeTo()
AND pt_insert_date=to_char(now(), 'YYYYMMDD')
AND parameter like 'FilmDownTime0%'
ORDER BY starttime DESC
) A
GROUP BY 1
```
这里我使用了 `$__timeFrom()` 和 `$__timeTo()` 函数来获取时间范围,您也可以根据需要修改这些函数来指定自己的时间范围。
阅读全文