[img]http://dl.iteye.com/upload/picture/pic/84841/56511df5-1fec-3fd6-b9c1-55af660c0597.jpg[/img]
我想要在上图中五条记录中搜出来从2011/3/23 00:00:00到2011/3/24 00:00:00的记录,也就是搜出来前四条记录。
请问sql语句怎么写啊?
最好把纯java语句写出来也是最好的啦,谢谢各位
数据库名是 :temporary
数据库为 oracle 10G
这个是一天之内,最晚的那条记录
我想要在上图中五条记录中搜出来从2011/3/23 00:00:00到2011/3/24 00:00:00的记录,也就是搜出来前四条记录。
请问sql语句怎么写啊?
最好把纯java语句写出来也是最好的啦,谢谢各位
数据库名是 :temporary
数据库为 oracle 10G
select * from temporary where trunc(createtime)=trunc(sysdate)
select * from temporary where to_char(createtime,'yyyy-mm-dd')=to_char(sysdate,'yyyy-mm-dd')
select *
from temporary t
where t.createtime between
to_date('2011-3-23 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and
to_date('2011-3-23 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
这个是一天之内,最晚的那条记录
select * from (select * from (select *
from temporary t
where t.createtime between
to_date('2011-3-23 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and
to_date('2011-3-23 23:59:59', 'YYYY-MM-DD HH24:MI:SS')) order by createtime desc)where rownum<2 ;
判断ID的总个数
select count(id) from temporary
while(rs!=null&&rs.next()){
System.out.println("今天的人数:"+rs.getInt(1));
}
判断当天的(今天)id的个数
判断任意一天的id的个数:
select count(id) from (select * from (select * from temporary where trunc(createtime)=trunc(sysdate)) order by createtime desc)";
while(rsl.next()){
System.out.println("总的人数:"+rsl.getInt(1));
}
判断今天前一天的记录:
SELECT * FROM TEMPORARY where trunc(createtime) =trunc(sysdate-1)
判断距今天前十天的记录:
SELECT * FROM TEMPORARY where trunc(createtime) =trunc(sysdate-10)
本文介绍如何使用SQL语句查询Oracle数据库中特定日期区间内的数据,包括获取某一天内的最早和最晚记录,计算一天内记录总数,判断特定日期的记录数量,以及查询指定日期范围的数据。
171万+

被折叠的 条评论
为什么被折叠?



