Received: from Donald.bks ([203.145.133.16]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9J6R0P55070 for ; Fri, 19 Oct 2001 02:27:01 -0400 (EDT) (envelope-from bhuvansql@yahoo.com) Received: from Larry.bks (root@Larry.bks [200.2.1.10]) by Donald.bks (8.11.6/8.11.2) with ESMTP id f9J6PrA01348; Fri, 19 Oct 2001 11:55:53 +0530 Received: from localhost (bhuvan@localhost) by Larry.bks (8.9.3/8.8.5) with ESMTP id LAA22152; Fri, 19 Oct 2001 11:50:04 +0530 X-Authentication-Warning: Larry.bks: bhuvan owned process doing -bs Date: Fri, 19 Oct 2001 11:50:04 +0530 (IST) From: Bhuvan A X-Sender: bhuvan@Larry.bks To: Oleg Lebedev cc: Postgres SQL Mailing List Subject: Re: COUNT func In-Reply-To: <3BCF2F6D.D404B26@waterford.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200110/273 X-Sequence-Number: 5226 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 >