Re: Using || operator to fold multiple columns into one - Mailing list pgsql-sql

From Rosser Schwarz
Subject Re: Using || operator to fold multiple columns into one
Date
Msg-id 37d451f70912231304i3515e575x69b31638962739a6@mail.gmail.com
Whole thread Raw
In response to Re: Using || operator to fold multiple columns into one  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Using || operator to fold multiple columns into one  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: short-cutting if sum()>constant
Next
From: Craig Ringer
Date:
Subject: Re: Using || operator to fold multiple columns into one