Re: COUNT func

From: Bhuvan A <bhuvansql(at)yahoo(dot)com>
To: Oleg Lebedev <olebedev(at)waterford(dot)org>
Cc: Postgres SQL Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: COUNT func
Date: 2001-10-19 06:20:04
Message-ID: Pine.LNX.4.20.0110191148400.20805-100000@Larry.bks
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
>

In response to

  • COUNT func at 2001-10-18 19:37:17 from Oleg Lebedev

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-10-19 06:53:39 Re: Table Constraints with NULL values
Previous Message Bhuvan A 2001-10-19 06:01:45 Need a VIEW without SUB-SELECT