Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> grouping
oracle 9
I have a table with task_id , order_id , and status in
My problem is I only want to get orders out that have all "COMP" or ALL
"COMC" or all are "COM*"
The sql works but is very very slow
Any ideas please
task id order id status 1 a COMP 2 a COMP 3 b COMP 4 c COMP 5 c COMC 6 c COMC 7 d COMP 8 d COMP 9 d ACT 10 d EXC 11 d ACT 12 e COMP 13 e COMC 14 e ACT 15 f COMP 16 f COMC 17 g ACT
Sql problem
select distinct t.order_id from tasks t,tasks t0
where t.order_id = t0.order_id and t.STATUS = 'COMP' and t.order_id not in ( select order_id from wm_tasks where STATUS NOt in ('COMP' ,'COMC') and order_id in ( select distinct t.order_id from wm_tasks t,wm_tasks t0 where t.order_id = t0.order_id and t.STATUS = 'COMP'));Received on Tue Jan 30 2007 - 15:02:30 CST