Re: creating view - conditional testing in construct

From: Casey Allen Shobe <casey(at)shobe(dot)info>
To: rterry(at)pacific(dot)net(dot)au
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: creating view - conditional testing in construct
Date: 2009-10-25 16:07:23
Message-ID: a6a62ed60910250907g71f4b075w8a481845fa28e515@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, Oct 24, 2009 at 5:41 AM, richard terry <rterry(at)pacific(dot)net(dot)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
casey(at)shobe(dot)info

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Oisin 2009-10-25 17:52:52 Import of GML into PostgreSQL 8.4
Previous Message richard terry 2009-10-24 09:41:40 Re: creating view - conditional testing in construct