您的位置:首页 > 数据库 > MySQL

Mysql取每小时的一条记录

2016-04-14 14:15 302 查看
SELECT * FROM (
SELECT
s.sensor_data,s.get_date,s.sensor_name,
DATE(get_date) AS d,
SUBSTRING(get_date,12,2) as h
FROM t_env_sensor s where s.sensor_type=5 and s.mod_id=1 and date_format(s.get_date,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d')
ORDER BY get_date DESC
) t_env_sensor
GROUP BY d,h
测试可用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: