select * from table where s_time>'2004-12-23 08:03:30' and e_time<'2004-12-23 08:20:30'
解决方案 »
- oracle 新建用户使用原数据库问题
- java.lang.Exception: IOException in sending Request :: Connection refused 解決方法一
- Oracle 函数大全(字符串函数,数学函数,日期函数,逻辑运算函数,其他函数)
- 我电脑上的 Oracle 在安装了 JDK(J2EE) 1.4 之后 Enterprise manager console 不能启动了!!!
- 如何撤消用户的权限
- 帮我看看这条语句为什么查不出数据?
- 如何寻找最大的一笔数据?
- 一个挺简单的问题,请高手指教!
- 如何用程序实现将Excel中的数据导入Oracle9i中?
- 给排序后的记录多加一列,表示序列,从1开始,怎么做?
- 如何判断一个表分区的名字是否存在并是什么名字
- SMON问题
是s_time e_time
谢谢!
WHERE TO_CHAR(s_time, 'yyyymmddhh24miss') > '20041223080330' AND
TO_CHAR(e_time, 'yyyymmddhh24miss') < '20041223082030'
和 loveutoo(Mars) 一样,记录集中会少前面和后面两条记录
WHERE (s_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')) or
(s_time<to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss')) or
(s_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time>to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'));
select * from tb where 2004-12-23 08:01:30>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and 2004-12-23 08:21:30
<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')成立么?
我要的记录集就是上面的列出来的几条?不好意思,你再看一下吧!谢谢!
bzszp的语句我测试一下!谢谢!稍等
1 2004-12-23 08:01:30 2004-12-23 08:06:30
2 2004-12-23 08:06:30 2004-12-23 08:11:30
3 2004-12-23 08:11:30 2004-12-23 08:16:30
4 2004-12-23 08:16:30 2004-12-23 08:21:30
我想截取:2004-12-23 08:03:30 2004-12-23 08:20:30之间的上面这段数据,sql语句该如何写?
select * from yourtable where (s_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
or
(s_time < to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss'))
or
(s_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
--取中间数据
(s_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))or
--包含起始数据
(s_time < to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss'))or
--包含结束数据
(s_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
注意,是e_time用>= 与参数的开始日期比,s_time用>= 与参数的结束日期比。
select * from tb where e_time>=to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and s_time<=to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')