Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: grouping

Re: grouping

From: Dieter Noeth <dnoeth_at_gmx.de>
Date: Wed, 31 Jan 2007 07:50:34 +0100
Message-ID: <eppe7u$f0j$1@online.de>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US