Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: grouping
gb wrote:
> 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*"
select distinct order_id
from tab t1
where not exists
(select * from tab t2
where t1.order_id = t2.order_id
and status not in ('COMP', 'COMC')
)
or
select order_id
from tab
group by order_id
having count(case when status in ('COMP', 'COMC') then 0 else 1 end) = 0
Dieter Received on Wed Jan 31 2007 - 00:50:34 CST
![]() |
![]() |