select t.*
from MONITOR_TEST t
where t.collect_date in
(select max(collect_date)
from MONITOR_TEST
where collect_date < to_date('2016-11-08', 'yyyy-mm-dd')
and collect_date > to_date('2016-11-04', 'yyyy-mm-dd'))
union
select t.*
from MONITOR_TEST t
where t.collect_date in
(select min(collect_date)
from MONITOR_TEST
where collect_date < to_date('2016-11-08', 'yyyy-mm-dd')
and collect_date > to_date('2016-11-04', 'yyyy-mm-dd'))
from MONITOR_TEST t
where t.collect_date in
(select max(collect_date)
from MONITOR_TEST
where collect_date < to_date('2016-11-08', 'yyyy-mm-dd')
and collect_date > to_date('2016-11-04', 'yyyy-mm-dd'))
union
select t.*
from MONITOR_TEST t
where t.collect_date in
(select min(collect_date)
from MONITOR_TEST
where collect_date < to_date('2016-11-08', 'yyyy-mm-dd')
and collect_date > to_date('2016-11-04', 'yyyy-mm-dd'))
解决方案 »
- 求教
- 求一条SQL语句的优化
- 如何让ORACLE触发器只对某一行有用
- 问一下存储过程!
- 我用PL\SQL Developer,怎么Number太长,他总是用科学计数法.有没有办法不这样?
- 急!!!!!怎样快速杀死一个会话?
- OracleOraHome92ManagementServer和OracleOraHome92TNSListener服务无法启动
- 执行存储过程,出现按 8192 扩展段 (在撤消表空间 'UNDOTBS1' 中)错误
- 菜鸟发问,有关SQL*PLUS的初级问题
- 绿三角、红五星
- oracle 11g 过一会就会断开连接,提示无监听程序,但是服务里面监听又是开启的
- expdp 导出版本不兼容
in 可以换成 =
union 可以换成 UNION ALL
select max(collect_date),min(collect_date)
from MONITOR_TEST
where collect_date < to_date('2016-11-08', 'yyyy-mm-dd')
and collect_date > to_date('2016-11-04', 'yyyy-mm-dd')
然后再去比较业务
2、collect_date 上存在合理的索引效率会更高些