码迷,mamicode.com
首页 > 其他好文 > 详细

查询语句,将一天所有记录按小时划分

时间:2017-01-09 11:19:36      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:where   esc   to_char   为知笔记   round   笔记   data-   mon   font   

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 




查询语句,将一天所有记录按小时划分

标签:where   esc   to_char   为知笔记   round   笔记   data-   mon   font   

原文地址:http://www.cnblogs.com/samwang88/p/f3c50dbc0ae723c69d5ce6dbb51dc731.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!