Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group