Counting the number of distinct rows returned

Поиск
Список
Период
Сортировка
От Drew Whittle
Тема Counting the number of distinct rows returned
Дата
Msg-id 4.1.19990819115506.00cfd890@pern.csarc.otago.ac.nz
обсуждение исходный текст
Ответ на Re: [SQL] index on more-than-one columns?  (Oleg Bartunov <oleg@sai.msu.su>)
Ответы Re: [SQL] Counting the number of distinct rows returned  ("tjk@tksoft.com" <tjk@tksoft.com>)
Re: [SQL] Counting the number of distinct rows returned  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
How can I return the number of records (ie a count(user_id)) when using a
statement like this:

select distinct user_id from sales_by_region;

I have tried things like:

select count(distinct user_id) from sales_by_region (parse error)
select distinct count(user_id) from sales_by_region (useless because count
is performed before the distinct)

HELP!

Thanks,

Drew




В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [SQL] Using intersect in subquery
Следующее
От: Doug Younger
Дата:
Сообщение: Problems using count() with a join