From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: coalesce a null to a char ? |
Date: | 2009-04-06 22:27:15 |
Message-ID: | 49DA81C3.7000503@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 06/04/2009 22:55, Gauthier, Dave wrote:
> How can I do this....
>
> selcet coalesce((select 'y' from foo where name = f.name),'n') from foo f where...
>
> So the query returns a "y" or "n" depending on whether or not the subquery is null.
Are you sure that the subquery is returning any rows? Try something like
this instead (not tested):
select
case
when exists(select 1 from foo where name = f.name) then 'y'
else 'n'
end
from foo....
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Kashmir | 2009-04-06 22:32:17 | Re: user defined aggregate for percentile calculations |
Previous Message | Kevin Grittner | 2009-04-06 22:05:33 | Re: tsearch2 dictionary for statute cites |