pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jdmorgan <jdmorgan@unca.edu>
To: Matheus de Oliveira <matioli.matheus@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: case statement to cath nulls on joined tables
Date: Fri, 03 Feb 2012 13:34:53 -0500
Message-ID: <4F2C28CD.5010809@gmail.com> (raw)
In-Reply-To: <CAJghg4Kyw9HkjHFGXdS+_xL4jPVNxBLqOhgnhN01JtwK2FHtug@mail.gmail.com>
References: <CA+N3S5q5KZhi6ggjQAO2XPSE5OXvt0eQyO0s63bs-1Sjce0AYQ@mail.gmail.com>
	<CAJghg4+Uk2+Dh6smvG2n8-xKGCLGT7Ltx_c-cXP3_Gbm6O0RXQ@mail.gmail.com>
	<CAJghg4Kyw9HkjHFGXdS+_xL4jPVNxBLqOhgnhN01JtwK2FHtug@mail.gmail.com>

Thanks Matheus.  The coalesce method worked like a champ.

Cheers,
Derek

On 2/3/2012 10:09 AM, Matheus de Oliveira wrote:
> Even better:
>
> SELECT COALESCE(value_of_interest, 'more friendly message') 
> value_of_interest
> From poly_table left outer join data_table one poly_table.common_id = 
> data_table.common_id
>
> --
> Matheus de Oliveira
>
>
>
>
> On Fri, Feb 3, 2012 at 1:05 PM, Matheus de Oliveira 
> <matioli.matheus@gmail.com <mailto:matioli.matheus@gmail.com>> wrote:
>
>     Try that:
>
>     SELECT address, CASE WHEN value_of_interest IS NULL THEN 'more
>     friendly message' ELSE value_of_interest END value_of_interest
>
>     From poly_table left outer join data_table one
>     poly_table.common_id = data_table.common_id
>
>
>     --
>     Matheus de Oliveira
>
>
>
>
>
>     On Fri, Feb 3, 2012 at 10:45 AM, John Morgan <jdmorgan@unca.edu
>     <mailto:jdmorgan@unca.edu>> wrote:
>
>         Hello,
>
>         I am doing a left outer join between a polygon table and a
>         data table.
>          Everything
>         returns fine from this join as expected.  However, there are
>         cases where
>         there isn?t data for a given polygon and this return as the
>         expected null
>         in the result set.  I would like to utilize something like a
>         case statement
>         to catch the nulls and return a ?more friendly? message.  I
>         have tried
>         unsuccessfully to use the following logic:
>
>         *Select case value_of_interest null then ?more friendly
>         message? else
>         value_of_interest end*
>
>         *From poly_table left outer join data_table one
>         poly_table.common_id =
>         data_table.common_id*
>
>         If someone could let me know where I am going wrong it would
>         be greatly
>         appreciated.
>
>         Cheers,
>
>         Derek
>
>
>


-- 
Derek @ NEMAC

view thread (4+ messages)

Message-ID: <4F2C28CD.5010809@gmail.com>
Permalink:  ../4F2C28CD.5010809@gmail.com/
Also on:    postgresql.org/message-id/4F2C28CD.5010809@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: jdmorgan@unca.edu, matioli.matheus@gmail.com
  Subject: Re: case statement to cath nulls on joined tables
  In-Reply-To: <4F2C28CD.5010809@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox