If function available?

From: Francisco Reyes <lists(at)natserv(dot)com>
To: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: If function available?
Date: 2001-11-20 15:17:33
Message-ID: 20011120101503.V75685-100000@zoraida.natserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I am looking to do something like:

SELECT
Field1
, COUNT( IF( Field1 = 1, Field1, NULL ) ) AS one
, SUM( IF( Field1 = 2, Field1, NULL ) ) AS two
FROM
Table
GROUP BY
Field1

I tried it from the psql prompt and didn't work. Is there an IF or
IIF function that can be used on a select query?

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-11-20 15:21:04 Re: Emergency backup question.
Previous Message Rob Arnold 2001-11-20 13:34:55 Re: 2 newbie questions