SELECT DISTINCT and count(1)

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

SELECT DISTINCT and count(1)

От:
A B <gentosaker@gmail.com>
Дата:
Hi.
I need to do a

select distinct userid  from  usertable,  where ;

and then count the rows in the result

How do I do that?

Re: SELECT DISTINCT and count(1)

От:
A B <gentosaker@gmail.com>
Дата:
Thank you both for both for your replies.

2009/7/16 Maximilian Tyrtania :
> am 16.07.2009 11:57 Uhr schrieb A B unter gentosaker@gmail.com:
>
>> Hi.
>> I need to do a
>>
>> select distinct userid  from  usertable,  where ;
>>
>> and then count the rows in the result
>>
>> How do I do that?
>
> Try:
>
> select count(distinct(userid))  from  usertable,  where
> ;
>
> Best wishes from Berlin,
>
> Maximilian Tyrtania
>
>
>

Re: SELECT DISTINCT and count(1)

От:
nobs@nobswolf.info (Emil Obermayr)
Дата:
On Thu, Jul 16, 2009 at 11:57:56AM +0200, A B wrote:
> 
> select distinct userid  from  usertable,  where ;
> 
> and then count the rows in the result

make it a subselect and count in the outer select:

select count(*) as num from (select distinct...) dummy;
FAQ