Thread: DISTINCT and COUNT help

DISTINCT and COUNT help

From
Julie Keywell
Date:
Hi there!

I would like to count the number of distinct values in a column.  Is
there any way to combine DISTINCT and COUNT and if so, what is the
syntax?

Thanks for your help!
Julie






Re: DISTINCT and COUNT help

From
Chris
Date:
Hi Julie,

>I would like to count the number of distinct values in a column.  Is
>there any way to combine DISTINCT and COUNT and if so, what is the
>syntax?

Sure is.

SELECT DISTINCT column, COUNT(column) FROM table GROUP BY column;

HTH,

-----------------
      Chris Smith
http://www.squiz.net/




Re: DISTINCT and COUNT help

From
Manfred Koizar
Date:
On Fri, 28 Jun 2002 00:10:56 -0500, Julie Keywell <julie@iparenting.com> wrote:
>I would like to count the number of distinct values in a column.  Is
>there any way to combine DISTINCT and COUNT and if so, what is the
>syntax?
Julie, it's so obvious, you didn't dare to think of it :-)

SELECT COUNT(DISTINCT col) FROM t;

Servus
 Manfred



Re: DISTINCT and COUNT help

From
Ludwig Lim
Date:
Julie:

--- Julie Keywell <julie@iparenting.com> wrote:
> Hi there!
>
> I would like to count the number of distinct values
> in a column.  Is
> there any way to combine DISTINCT and COUNT and if
> so, what is the syntax?

try SELECT COUNT(DISTINCT(<column name>))
    FROM .....


ludwig


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com