查询语句,按照时间排序,取前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;

上一篇:开源战棋 SLG 游戏框架设计思考(二)规则系统要考虑的因素


下一篇:JavaWeb项目中获取对Oracle操作时抛出的异常错误码