From: Tomasz Myrta <jasiek@klaster.net>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sql question regarding count(*)
Date: Thu, 06 Mar 2003 13:00:52 +0100
Message-ID: <3E673874.5030606@klaster.net> (raw)
References: <200303061702.26339.mallah@trade-india.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jasiek@klaster.net, mallah@trade-india.com
Subject: Re: sql question regarding count(*)
In-Reply-To: <3E673874.5030606@klaster.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox