Received: from mail1.waterford.org (mail1.waterford.org [205.124.117.6]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9IJIMP23101 for ; Thu, 18 Oct 2001 15:18:22 -0400 (EDT) (envelope-from olebedev@waterford.org) Received: from waterford.org ([205.124.138.93]) by mail1.waterford.org (Netscape Messaging Server 3.56) with ESMTP id 440 for ; Thu, 18 Oct 2001 13:08:29 -0600 Message-ID: <3BCF2F6D.D404B26@waterford.org> Date: Thu, 18 Oct 2001 13:37:17 -0600 From: Oleg Lebedev X-Mailer: Mozilla 4.72 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Postgres SQL Mailing List Subject: COUNT func Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Archive-Number: 200110/259 X-Sequence-Number: 5213 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