sql,按照时间排序,取前N条

2019/06/20 11:30
阅读数 30
mysql:
SELECT * from 
(SELECT H_TEMPERATURE,TH_TIME FROM wenshidu 
WHERE TH_TIME <= STR_TO_DATE('2016-03-16 10:04:52','%Y-%m-%d %H:%i:%s')
order by  TH_TIME desc)  as total limit 0,8;
 
oracle:
SELECT * from 
(SELECT H_HUMIDITY FROM HOME_MONITOR 
WHERE H_TIME <= to_date( ' 2016-03-01 10:04:52 ' ,'yyyy-MM-dd HH24:mi:ss')   
order by  H_TIME desc ) where rownum<=8;

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部