Re: sql question regarding count(*)

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sql question regarding count(*)
Date: 2003-03-06 12:00:52
Message-ID: 3E673874.5030606@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Mitchell 2003-03-06 14:31:56 Re: Cancelling Queries
Previous Message Rajesh Kumar Mallah 2003-03-06 11:32:26 sql question regarding count(*)