[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] multiple count functions in a select statement
From:       Oliver Elphick <olly () lfix ! co ! uk>
Date:       2004-05-31 20:32:41
Message-ID: 1086035561.27765.89.camel () linda
[Download RAW message or body]

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@lfix.co.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 


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic