X-Original-To: pgsql-sql@postgresql.org Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 7F65E47611A for ; Thu, 6 Mar 2003 07:16:03 -0500 (EST) Received: from klaster.net (pc126.krakow.cvx.ppp.tpnet.pl [213.76.38.126]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 6C2E12B898; Thu, 6 Mar 2003 12:58:22 +0100 (CET) Message-ID: <3E673874.5030606@klaster.net> Date: Thu, 06 Mar 2003 13:00:52 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Rajesh Kumar Mallah Cc: pgsql-sql@postgresql.org Subject: Re: sql question regarding count(*) References: <200303061702.26339.mallah@trade-india.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/167 X-Sequence-Number: 12207 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