admin管理员组

文章数量:1401778

I am working with GridDB and trying to run a TQL (TimeSeries Query Language) query on a TimeSeries container. However, I keep encountering a syntax error.

I have a TimeSeries container named sensor_data, which has the following schema:

Column Name Data Type timestamp TIMESTAMP temperature DOUBLE humidity DOUBLE

I want to retrieve sensor readings where the temperature is above 30 degrees for the last 24 hours. Here's my TQL query:

SELECT Avg(temperature) FROM sensor_data  
WHERE timestamp > TIMESTAMPADD(HOUR, -24, NOW())  
AND temperature > 30;
SELECT Avg(humidity) FROM sensor_data  
WHERE timestamp > TIMESTAMPADD(HOUR, -24, NOW())  
AND temperature > 30;

However, when I execute this query, I get the following error:

Syntax error near 'timestamp' at line 2Syntax error near 'timestamp' at line 2Syntax error near 'timestamp' at line 2

What I've Tried: Changing TIMESTAMPADD(HOUR, -24, NOW()) to NOW() - INTERVAL 24 HOUR (but GridDB does not support INTERVAL).

Using TO_TIMESTAMP around NOW() but still get errors.

Expected Output: A filtered result with Average value where temperature/humidity values are greater than 30 (or given value) and timestamps are within the last 24 hours.

Actual Output: A syntax error on the timestamp column.

Question: Does GridDB require a different way to filter timestamps in a TimeSeries container?

How can I properly filter results based on timestamps in the last 24 hours?

Any guidance would be greatly appreciated!

本文标签: GridDB TQL Query Fails with quotSyntax Errorquot on TimeSeries ContainerStack Overflow