选择每小时查询

问题描述:

我有一个简单的气象站数据库,其中包含示例内容:

I have a simple weather station DB with example content:

time                humi1 humi2 light pressure station-id temp1 temp2
----                ----- ----- ----- -------- ---------- ----- -----
1530635257289147315 66    66    1834  1006     bee1       18.6  18.6
1530635317385229860 66    66    1832  1006     bee1       18.6  18.6
1530635377466534866 66    66    1829  1006     bee1       18.6  18.6

Station每分钟写入一次数据.我不希望所有系列都获得SELECT,而是每个小时(或者说第60个系列,简而言之)编写的系列.我该如何实现?

Station writes data every minute. I want to get SELECT not with all series, but just series written every hour (or every 60th series, simply said). How can I achieve it?

我尝试使用...WHERE time % 60 = 0进行实验,但是没有用.似乎time列不允许任何数学运算(/%等).

I tried to experiment with ...WHERE time % 60 = 0, but it didn`t work. It seems, that time column doesnt permit any math operations (/, %, etc).

Group by和其中一个功能可以完成您想要的操作:

Group by along with a one of the functions can do what you want:

SELECT FIRST("humi1"), FIRST("humi2"), ... GROUP BY time(1h)

我想对于大多数气候数据来说,您希望使用MEAN或MEDIAN,而不是每小时都需要一个数据点

I would imagine for most climate data you'd want the MEAN or MEDIAN rather than a single data point every hour

更复杂的示例