Re: count(1) return 0?

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Zak McGregor <zak(at)mighty(dot)co(dot)za>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: count(1) return 0?
Date: 2004-03-01 00:55:15
Message-ID: 404289F3.7020102@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Zak McGregor wrote:
> Hi all
>
> is it possible to get a count(1) statemment, for example here:
>
> select count(1) from results where fixture=4916 and winner=away group by winner;
>
> to return a 0 value instead of absolutely nothing if no rows match fixture=4916
> and winner=away? I get absolutely no results at all.
>
>
> select count(1) from results where fixture=4916 and winner=home group by winner;
> count
> -------
> (0 rows)
>
> any ideas please?

Not really sure I understand what you want, but try something like this:

select case when count(*) > 0 then ''t'' else ''f'' end from ...

--
Bill Moran
Potential Technologies
http://www.potentialtech.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zak McGregor 2004-03-01 01:02:29 Re: count(1) return 0?
Previous Message Zak McGregor 2004-03-01 00:14:56 count(1) return 0?