multiple counts using CASE

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: multiple counts using CASE
Date: 2002-03-19 14:06:31
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB0452E0F4@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Howdy

Running Postgres 7.1.3 on RedHat Linux 7.2 kernel
2.4.7 - 10.

Wonder if it is possible to get multiple counts
from ONE query using the CASE statement.

I'm trying to set something up like this:

select count (*)
case
when logic = '1' then 'First'
when logic = '2' then 'Second'
when logic = '3' then 'Third'
else 'Error'
end as 'Count'
from temp_table
;

I wonder if this is even possible? Maybe I can
try to create a variable (place holder) and
loop? I don't want to have to create many
versions of one program to count for each "logic"
in the table.

Suggestions?

Thanks!

-X

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric Lee Green 2002-03-19 15:08:54 Re: Performance issues
Previous Message Jeff Davis 2002-03-19 13:22:48 Notify argument?