Re: multiple count functions in a select statement

From: Duane Lee - EGOVX <DLee(at)mail(dot)maricopa(dot)gov>
To: Duane Lee - EGOVX <DLee(at)mail(dot)maricopa(dot)gov>, "'Jeannie Stevenson'" <webteam(at)wes-state(dot)com>, "'postgresql'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: multiple count functions in a select statement
Date: 2004-06-01 17:04:30
Message-ID: 64EDC403A1417B4299488BAE87CA7CBF01CD0E48@maricopa_xcng0
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sent a little too quickly the sql should look like this:

select count_1, count_2 from
(select count(*) AS count_1 from leads where ad_code = '555') AS DMY1,
(select count(*) AS count_2 from leads where ad_code = '222') AS DMY2
;

-----Original Message-----
From: Duane Lee - EGOVX
Sent: Tuesday, June 01, 2004 9:54 AM
To: 'Jeannie Stevenson'; postgresql
Subject: RE: [GENERAL] multiple count functions in a select statement

If I understand what you're asking try:

select count_1, count_2 from

(select count(*) AS count_1 from leads where ad_code = '555'),
(select count(*) AS count_2 from leads where ad_code = '222')
;
Duane

-----Original Message-----
From: Jeannie Stevenson [mailto:webteam(at)wes-state(dot)com]
Sent: Thursday, May 27, 2004 9:39 AM
To: postgresql
Subject: [GENERAL] multiple count functions in a select statement

Hello list

I'm a MSSQL convert and I'm running postgresql 7.2

I'm trying to create a statement in which display multiple counts on a table

In MSSQL I would use

select
count_1=(select count(ad_code) AS "CP" from leads where ad_code = '555'),
count_2=(select count(ad_code) AS HED" from leads where ad_code = '222'),
etc


I've searched the docs but to avail.

Any help, suggestions, pointers, would be appreciated

Thanks

Jeannie

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2004-06-01 17:13:41 Re: Problems with pgsql mail servers?
Previous Message Duane Lee - EGOVX 2004-06-01 16:53:56 Re: multiple count functions in a select statement