select t1.* from tab t1,tab t2
where t1.a=t2.b
and t1.e>t2.f
and rownum=1;
where t1.a=t2.b
and t1.e>t2.f
and rownum=1;
解决方案 »
- ORACLE 错误 959/表空间不存在错误
- 安装完ORACLE 11g之后运行sqlplus出现错误!还有ORACLE的1521端口没有启动!
- rman的catalog tablespace删除了怎么办?
- 请各位大侠帮个忙,如何oracle中导出数据到sql server中去
- 跪求一oracle函数。
- 请教修改oralce代理问题
- About Sequence!
- 请教一个关于ORACLE HTTP的问题
- 请问oracle9iAS是免费的吗?怎么样才可以获得?另外在正版的oracle9i数据库光盘中,有没有附带它?
- 有两个出错提示均为“无效列名”的错误:
- 请高手帮忙看一下我的程序错在哪里
- 游标的问题,请高手帮忙!
不知道你是不是这个意思
如下表:
列 id1 id2 e f
1 2 84 78
2 1 13 27
1 2 76 63
1 1 23 48
1 3 42 27
1 3 32 16
2 1 41 25
3 2 24 12
1 3 92 42要求查询结果为:
id1 id2
1 2
1 3
3 2解析:
因为id1=1 and id2=2的两行数据都是e>f
因为id1=1 and id2=3的三行数据都是e>f
因为id1=3 and id2=2的一行数据是e>f
都符合要求!而id1=2 and id2=1的两行数据一个是e>f,一个是e<f,
id1=1 and id2=1的一行数据是e<f,
所有不符合要求!
select distinct id1, id2 from tab where e>f
minus
select distinct id1, id2 from tab where e<f
如id1=1 and id2=3的三条数据,你上面的写法是用什么语句判断他的三条数据都符合e>f的?
Exactly, it should be:
select distinct id1, id2 from tab where e>f
minus
select distinct id1, id2 from tab where e<=f
id1 id2 e f
1 2 4 3
1 2 2 1
这个语句是否不能实现对每个id1,和id2的值相同的数据进行检测是否满足e>f???
a.workflow_type_id workflow_type_id, a.summary summary, b.NAME system_name, a.start_date start_date,
a.end_date end_date, a.deadline deadline, a.system_status descr
FROM workflow a, systems b, workflow_monitor c, workflow_type d, task e
WHERE a.system_id = b.system_id AND
a.system_id = d.system_id(+) and a.workflow_type_id = d.workflow_type_id(+) AND
a.system_id = e.system_id and a.workflow_id= e.workflow_id and
a.workflow_type_id = c.workflow_type_id and c.system_id = b.system_id AND c.user_id = 'admin'
AND a.system_id = '1' AND a.start_date > to_date('2003-01-01', 'yyyy-mm-dd') AND
a.start_date < to_date('2004-03-30', 'yyyy-mm-dd') AND NVL(a.WORKFLOW_STATUS, 2) = 0 AND
a.END_DATE is null and (SYSDATE <= a.deadline or a.deadline is null) and
e.END_DATE is null and NOT EXISTS (SELECT 'X' FROM task e where a.workflow_id=e.workflow_id and SYSDATE > e.deadline and e.deadline is not null)
ORDER BY a.start_date ASC
这个语句可以优化吗???我查找好几个小时才有结果!很慢!