Select every hour query

≡放荡痞女 提交于 2019-12-13 18:19:04

问题


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 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?

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).


回答1:


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

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

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

basic example, and more complex example



来源:https://stackoverflow.com/questions/51196425/select-every-hour-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!