Re: multiple count functions in a select statement

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Jeannie Stevenson <webteam(at)wes-state(dot)com>
Cc: postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: multiple count functions in a select statement
Date: 2004-05-31 20:32:41
Message-ID: 1086035561.27765.89.camel@linda
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-general

On Thu, 2004-05-27 at 17:38, Jeannie Stevenson wrote:
...
> 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

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

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"How precious also are thy thoughts unto me, O God! how
great is the sum of them! If I should count them, they
are more in number than the sand; when I awake, I am
still with thee." Psalms 139: 17,18

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2004-05-31 21:33:01 Re: Poatgresql database on more than one disk
Previous Message TroyGeek 2004-05-31 20:06:56 PostgreSQL Tablespaces