首页 > 代码库 > 查询语句,将一天所有记录按小时划分
查询语句,将一天所有记录按小时划分
mysql:
select
date_format(H_TIME,‘%H‘) as HOUR,
ROUND(AVG(H_TEMPERATURE),1) as TEMP,
ROUND(AVG(H_HUMIDITY),1) as HUMIDITY
FROM HOME_MONITOR Where date_format(H_TIME,‘%Y-%m-%d‘) = ‘2016-03-09‘
group by date_format(H_TIME,‘%H‘)
order by date_format(H_TIME,‘%H‘) desc
oracle:
select
to_char(H_TIME,‘HH24‘) as HOUR,
AVG(H_TEMPERATURE) as TEMP,
AVG(H_HUMIDITY) as HUMIDITY
FROM HOME_MONITOR Where to_char(H_TIME,‘yyyy-MM-dd‘) = ‘2016-03-09‘
group by to_char(H_TIME,‘HH24‘)
order by to_char(H_TIME,‘HH24‘) desc
来自为知笔记(Wiz)
查询语句,将一天所有记录按小时划分
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。