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

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;

 

posted @ 2019-06-20 11:30  Dkwestworld  阅读(3169)  评论(0编辑  收藏  举报