查询语句,将一天所有记录按小时划分
Posted Sam168666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查询语句,将一天所有记录按小时划分相关的知识,希望对你有一定的参考价值。
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
以上是关于查询语句,将一天所有记录按小时划分的主要内容,如果未能解决你的问题,请参考以下文章