pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bhuvan A <bhuvansql@yahoo.com>
To: Oleg Lebedev <olebedev@waterford.org>
Cc: Postgres SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: COUNT func
Date: Fri, 19 Oct 2001 11:50:04 +0530 (IST)
Message-ID: <Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks> (raw)
In-Reply-To: <3BCF2F6D.D404B26@waterford.org>



hi,
try this too..

select count(*),age,status from person  where age=40 and
status='MARRIED' group by age,status;
     
Regards,
Bhuvaneswar.

On Oct 18, Oleg Lebedev wrote:

> Hi,
> I am trying to count the number or rows in a table with similar field
> values. I want to do it in one table scan.
> In other words, say I want to count the number of rows in Person table,
> having age equal to 40, and the number of rows with status as 'married'.
> I want Person table to be scanned only once during this query.
> So, basically I want to do the following:
> SELECT COUNT(age=40), COUNT(status='married')
> FROM Person;
> 
> I tried to use aggregate functions with group by and having clauses, but
> I still can't figure it out (probably because of the lack of
> experience).
> Please help.
> Thanks,
> 
> Oleg
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 




view thread (4+ messages)

Message-ID: <Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks>
Permalink:  ../Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks/
Also on:    postgresql.org/message-id/Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bhuvansql@yahoo.com, olebedev@waterford.org
  Subject: Re: COUNT func
  In-Reply-To: <Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks>
  References: <3BCF2F6D.D404B26@waterford.org> <Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks>

* 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