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

Home -> Community -> Usenet -> comp.databases.oracle -> Re: need aid with this query

Re: need aid with this query

From: kibeha <kibeha_at_post6.tele.dk>
Date: 2 Feb 2004 05:05:43 -0800
Message-ID: <444b180d.0402020505.6ee99ab2@posting.google.com>

Hi

I'd use :

select

   customernumber,
   count(decode(customerbranch,null,1,null)) number_of_null_branches from t1
group by customernumber
having count(decode(customerbranch,null,1,null)) != 1;

The count(decode()) syntax will count null values in the customerbranch column.
The having clause ensures that you only get customernumbers with either zero or 2 or more null-values - so it also checks your requirement of only one null value :-)

Regards

KiBeHa Received on Mon Feb 02 2004 - 07:05:43 CST

Original text of this message

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