Re: Conactenating text with null values

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: olly(at)lfix(dot)co(dot)uk
Cc: "Gregory S(dot) Williamson" <gsw(at)globexplorer(dot)com>, Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Conactenating text with null values
Date: 2004-11-05 11:51:11
Message-ID: 1099655471.6361.80.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[snip]
> SELECT TRIM(TRIM(TRIM(COALESCE(s_house,'') || ' ' ||
> COALESCE(s_post_dir,'')) || ' ' || COALESCE(s_street ,'')) || ' ' ||
> COALESCE(s_suffix,'')) FROM parcels WHERE s_pin = '1201703303520';
>
> The TRIMs are to remove surplus spaces from inside the result string.
Avoiding the inner trims:

SELECT TRIM(
COALESCE(s_house || ' ','')
|| COALESCE(s_post_dir || ' ','')
|| COALESCE(s_street || ' ','')
|| COALESCE(s_suffix,'')
) FROM parcels WHERE s_pin = '1201703303520';

Looks a bit more understandable :-)

Cheers,
Csaba.

>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Antony Paul 2004-11-05 12:01:50 Characters used for pattern matching with like
Previous Message Oleg Bartunov 2004-11-05 11:19:27 Re: TSearch2: Problems with compound words and stop words