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

Home -> Community -> Usenet -> c.d.o.server -> Re: HELP! Having Count Question

Re: HELP! Having Count Question

From: <ctcgag_at_hotmail.com>
Date: 19 Dec 2002 19:57:49 GMT
Message-ID: <20021219145749.353$LV@newsreader.com>


kellywh_at_hotmail.com (oranewbie) wrote:
> I'm running counts against a table with 15,467,245 rows.
>
> When I run a count on a table using distinct(id) I get the following
> results:
>
> select count(distinct(id)) from emp;
> ------------------------------------
> 15,254,678
>
> 15,467,245 - 15,254,678 = 312,567 duplicates (easy right)

Are you sure there are no triplicates or higher replicates?

>
> However, when I try to pull off the duplicates with the having
> count(*). I get a different set of numbers:
>
> select count(*) from (select (account_id from emp having count(*) > 1
> group by
> account_id);
> -------------------------------------
> 302,831 duplicates

That query is hosed. 4 opening parenthesis, only 3 closing ones. It's not clear if the 'group by' and 'having' are supposed to be on the same query level but in the wrong order or on different levels. Also, is the essential column here account_id or just id?

Try this:
select redundancy, count(*) from

   ( select count(*) as redundancy from emp group by account_id)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Received on Thu Dec 19 2002 - 13:57:49 CST

Original text of this message

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