Search Postgresql Archives

Re: coalesce a null to a char ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux