Re: creating view - conditional testing in construct - Mailing list pgsql-novice

From Casey Allen Shobe
Subject Re: creating view - conditional testing in construct
Date
Msg-id a6a62ed60910250907g71f4b075w8a481845fa28e515@mail.gmail.com
Whole thread Raw
In response to Re: creating view - conditional testing in construct  (richard terry <rterry@pacific.net.au>)
List pgsql-novice
On Sat, Oct 24, 2009 at 5:41 AM, richard terry <rterry@pacific.net.au> wrote:

On Saturday 24 October 2009 09:28:44 richard terry wrote:

I've just implemented nathanial's solution and it solves my problem - thanks -
but I'd still be interested in sampel of using COALESCE.

select coalesce (v.title, '') || ' ' ||
    coalesce (v.firstname, '') || ' ' ||
    coalesce (v.surname, '') || '( ' ||
    coalesce (v.occupation, '') || ') ' ||
    coalesce (v.organisation, '') || ' ' ||
    coalesce (v.branch, '') as summary
from vworganisationsemployees as v;

But probably you want to use case, because with this approach you will still get an extra space padding if something is null.  With case, you can  handle that more elegantly, as already described.

Cheers,
-- 
Casey Allen Shobe

pgsql-novice by date:

Previous
From: richard terry
Date:
Subject: Re: creating view - conditional testing in construct
Next
From: "Oisin"
Date:
Subject: Import of GML into PostgreSQL 8.4