Re: sql question regarding count(*)

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message jasiek 2003-03-07 05:27:05 Re: Cancelling Queries
Previous Message Bruce Momjian 2003-03-07 01:31:02 Re: disable constraints