我现在要对Date类型的字段进行相减操作,得到相差的分钟需求The_date
2009-5-7 9:10:23
2009-5-7 8:20:36
2009-5-7 10:26:56从这个字段中选出最大的2个时间进行相减,求出其差值,单位为分钟或者秒钟
这里是2009-5-7 10:26:56 - 2009-5-7 9:10:23
谢谢大家了!
2009-5-7 9:10:23
2009-5-7 8:20:36
2009-5-7 10:26:56从这个字段中选出最大的2个时间进行相减,求出其差值,单位为分钟或者秒钟
这里是2009-5-7 10:26:56 - 2009-5-7 9:10:23
谢谢大家了!
解决方案 »
- oracle 用PL/SQL怎么导入视图
- ORA-00932: 数据类型不一致: 应为 -, 但却获得 CLOB
- 我的PL/SQL第一次执行语句都会出现“动态执行表不可访问,本会话的自动统计被禁止。在执行菜单里你可以禁止统计,或在v$session,v$sesstat和v$statname表获得选择权限”
- SOS SQL 关于年,月, 日统计
- SQL求救!!
- 请各位高手帮小弟建个视图,在线等待!
- 求一SQL解析
- date取出时候通常为2000/04/05式样,如何能成为2000/4/5式样
- 关于SQL操作问题 在触发器内 满足条件的填入数据 不满足的不填入数据
- Oracle CLOB字段清理
- 求教个sql算法问题
- 为什么序列号不存在?
(select the_date from (select the_Date,rownum rn from table order by the_Date desc) where rn=1) a,
(select the_date from (select the_Date,rownum rn from table order by the_Date desc) where rn=2) b
(max(the_date)-min(the_date))*86400 --秒
select ceil(((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('2008-04-30 23:59:59' , 'yyyy-mm-dd hh24-mi-ss'))) * 24 * 60) 相差分钟数 FROM DUAL;
/*
相差分钟数
----------
1441
1 row selected
*/
select ((select max(csrq) from dbzg)-(select max(csrq) from (select csrq from dbzg minus select max(csrq) from dbzg)))*1440 from dual;分钟,秒的话把1440换成24*60*60
select ((select max(the_date) from table)-(select max(the_date) from (select the_date from table minus select max(the_date) from table)))*1440 from dual;分钟,秒的话把1440换成24*60*60
select ceil(((To_date('2009-5-7 10:26:56', 'yyyy-mm-dd hh24-mi-ss') - To_date('2009-5-7 9:10:23', 'yyyy-mm-dd hh24-mi-ss'))) * 24 * 60) 相差分钟数 FROM DUAL;
/*
相差分钟数
----------
1441
1 row selected
*/
select ceil((To_date('2009-5-7 10:26:56', 'yyyy-mm-dd hh24-mi-ss') - To_date('2009-5-7 9:10:23', 'yyyy-mm-dd hh24-mi-ss')) * 24 * 60 * 60) 相差秒数 FROM DUAL;
/*
相差秒数
----------
86401
1 row selected
*/
select the_Date,rownum rn from table order by the_Date desc 中rn并不是顺序的,而是开始时的编号
寻找排序后的需要的位置行
select *
from (select rownum rn, tt.*
from (select * from tableName order by insert_time) tt)
where rn = 3
from (select rownum rn, tt.*
from (select * from tableName order by insert_time) tt)
where rn < 3)这样就可以只排序一次找出2个极值了,但是用了多次的select,不知道效率怎么样
(select the_date from (select the_Date,rownum rn from table order by the_Date desc) where rownum=1) a,
(select the_date from (select the_Date,rownum rn from table order by the_Date ) where rownum=1) b
select (a.the_date-b.the_date)/(24*60) from
(select the_date from (select the_Date from table order by the_Date desc) where rownum=1) a,
(select the_date from (select the_Date from table order by the_Date ) where rownum=1) b