dbTalk Databases Forums  

Re: HELP! Having Count Question

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Re: HELP! Having Count Question in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ctcgag@hotmail.com
 
Posts: n/a

Default Re: HELP! Having Count Question - 12-19-2002 , 01:57 PM






kellywh (AT) hotmail (DOT) com (oranewbie) wrote:
Quote:
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?

Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.