TimescaleDB时序分析函数
一、first()
SELECT
station_id,
first( jsondata, dcollectdate )
FROM
sc_customer_data
GROUP BY
station_id
2. last()
代码如下(示例):
SELECT
station_id,
LAST ( jsondata, dcollectdate )
FROM
sc_customer_data
GROUP BY
station_id
3.time_bucket()
time_bucket()每隔一段时间进行聚合查询
查询每隔五分钟的后一条数据
SELECT
time_bucket ( '5 minutes', dcollectdate ) AS TIME,
LAST ( jsondata, dcollectdate )
FROM
sc_customer_data
WHERE
station_id = 'ff1eed991ae90ad3e0c50bf14a0a3c21'
GROUP BY
TIME
ORDER BY
TIME DESC;
来源 https://blog.csdn.net/qq_38836114/article/details/123739472?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165234299716782391851447%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165234299716782391851447&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-30-123739472-null-null.nonecase&utm_term=TimescaleDB&spm=1018.2226.3001.4450
相关文章