Re: sql question regarding count(*) - Mailing list pgsql-sql

From Rajesh Kumar Mallah
Subject Re: sql question regarding count(*)
Date
Msg-id 200303071053.06820.mallah@trade-india.com
Whole thread Raw
In response to Re: sql question regarding count(*)  (Tomasz Myrta <jasiek@klaster.net>)
Responses Re: sql question regarding count(*)  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
Tomasz did you notice the two queries are totally differet on different
tables?



On Thursday 06 March 2003 05:30 pm, Tomasz Myrta wrote:
> 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

-- 

Regds
Mallah

----------------------------------------
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.


pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: disable constraints
Next
From: jasiek@klaster.net
Date:
Subject: Re: Cancelling Queries