[postgis-devel] case statement to cath nulls on joined tables

Chris Hodgson chodgson at refractions.net
Thu Feb 2 18:35:34 PST 2012


This isn't really the right place for this question (perhaps the 
postgresql users list?) but you'll find the syntax for the "case" 
conditional here:

http://www.postgresql.org/docs/9.1/static/functions-conditional.html

The "coalesce" function (also described on that page) also does what you 
want with less words.

Cheers,
Chris

On 12-02-02 06:25 PM, John Morgan 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
>
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20120202/8cfa7eb2/attachment.html>


More information about the postgis-devel mailing list