Re: sql question regarding count(*)

Поиск
Список
Период
Сортировка
От Tomasz Myrta
Тема Re: sql question regarding count(*)
Дата
Msg-id 3E673874.5030606@klaster.net
обсуждение исходный текст
Ответ на sql question regarding count(*)  (Rajesh Kumar Mallah <mallah@trade-india.com>)
Ответы Re: sql question regarding count(*)
Список pgsql-sql
Rajesh Kumar Mallah wrote:
> When does count(*) returns "o rows" ?
> and when does it return 1 row value being 0.
> 
> tradein_clients=# SELECT count(*)   from public.eyp_listing  where sno> 0 and 
> amount> 0  group by sno,branch,edition having count(distinct userid) > 1 ;
>  count
> -------
> (0 rows)
> 
> tradein_clients=#
> tradein_clients=#
> tradein_clients=# SELECT count(*) from public.users where userid=-1;
>  count
> -------
>      0
> (1 row)
> 
> tradein_clients=#
It's because of your having clause.
If count(*)=0 then having count(*)>1 results in no rows.

Regards,
Tomasz Myrta




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

Предыдущее
От: Rajesh Kumar Mallah
Дата:
Сообщение: sql question regarding count(*)
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Arrays Or Loop