pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rosser Schwarz <rosser.schwarz@gmail.com>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: Bryce Nesbitt <bryce2@obviously.com>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: Using || operator to fold multiple columns into one
Date: Wed, 23 Dec 2009 14:04:37 -0700
Message-ID: <37d451f70912231304i3515e575x69b31638962739a6@mail.gmail.com> (raw)
In-Reply-To: <4B31D86D.9030000@postnewspapers.com.au>
References: <4B31D619.1090706@obviously.com>
	<4B31D86D.9030000@postnewspapers.com.au>

On Wed, Dec 23, 2009 at 1:44 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:

> SELECT COALESCE( t_number::text, t:string::text, t_date::text, t_boolean::text) AS value;

Your invocation of COALESCE is incorrect -- it is n-ary, but it
returns its first non-NULL argument.  Instead, try:

SELECT
   COALESCE(t_number::text, '') ||
   COALESCE(t_string::text, '') ||
   COALESCE(t_date::text, '') ||
   COALESCE(t_boolean::text, '') ||
...

rls

-- 
:wq



view thread (7+ messages)  latest in thread

Message-ID: <37d451f70912231304i3515e575x69b31638962739a6@mail.gmail.com>
Permalink:  ../37d451f70912231304i3515e575x69b31638962739a6@mail.gmail.com/
Also on:    postgresql.org/message-id/37d451f70912231304i3515e575x69b31638962739a6@mail.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-sql@postgresql.org
  Cc: rosser.schwarz@gmail.com, craig@postnewspapers.com.au, bryce2@obviously.com
  Subject: Re: Using || operator to fold multiple columns into one
  In-Reply-To: <37d451f70912231304i3515e575x69b31638962739a6@mail.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