Query Output Formatting - Y/N Depending On Count - Mailing list pgsql-general

From Cameron B. Prince
Subject Query Output Formatting - Y/N Depending On Count
Date
Msg-id 001901c32166$c3665430$6401a8c0@rwl1
Whole thread Raw
In response to Re: UFS Logging on Solaris 8  (Andrew Sullivan <andrew@libertyrms.info>)
Responses Re: Query Output Formatting - Y/N Depending On Count  ("scott.marlowe" <scott.marlowe@ihs.com>)
Re: Query Output Formatting - Y/N Depending On Count  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Hi,

I need to output a Y or N depending on a count being greater than 0 or not.
I think I've seen a co-worker at a pervious job do something like this, but
I am unable to find any examples on the list or in the docs.

Here's my query:

SELECT a.col, COUNT(DISTINCT b.col) AS col_count
FROM table1 a
LEFT OUTER JOIN table2 b
ON a.col=b.col
GROUP BY a.col

So what I'm looking for is col_count to contain a Y if the count is greater
than 0, else an N.

Anyone know how to do this?

Thanks,
Cameron


pgsql-general by date:

Previous
From: "Guillaume Houssay"
Date:
Subject: Postgresql on SUN Server
Next
From: "scott.marlowe"
Date:
Subject: Re: Postgresql on SUN Server