Обсуждение: DISTINCT and COUNT help

Поиск
Список
Период
Сортировка

DISTINCT and COUNT help

От
Julie Keywell
Дата:
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

От
Chris
Дата:
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

От
Manfred Koizar
Дата:
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

От
Ludwig Lim
Дата:
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