List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:June 3 1999 6:52pm
Subject:Re: Count distinct and totals
View as plain text  
Darren Sweeney wrote:
> 
> Hi
> 
> I have a table which has a simple field: name
> 
> This field may contain the same name many times.
> 
> What i need to do is to count how many distinct names there are and how many times
> their name is listed to produce something like:
> 
> name | count
> ==========
> john   | 10
> Ted    | 15
> Pat    | 15
> 
> etc. etc.
> 
> I am struggling to be able to find the correct select formula ... i think i am
> looking too deeply as i am sure it is quite simple ...
> 
> I am trying:
> 
> select distinct name as name, count(distinct name) as count from tablename;
> 
> Thanks for any help
> 
> Darren

Will
 
select name, count(*) form table_name group by name

give you the results you are looking for?

-- 
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)
Thread
Count distinct and totalsDarren Sweeney3 Jun
  • Re: Count distinct and totalsSasha Pachev3 Jun
  • Re: Count distinct and totalsPaul DuBois3 Jun
Re: Count distinct and totalsDarren Sweeney3 Jun