选择每小时查询 [英] Select every hour query

查看:79
本文介绍了选择每小时查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

更复杂的示例

这篇关于选择每小时查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆