Re: Conactenating text with null values - Mailing list pgsql-general

From Csaba Nagy
Subject Re: Conactenating text with null values
Date
Msg-id 1099655471.6361.80.camel@localhost.localdomain
Whole thread Raw
In response to Re: Conactenating text with null values  (Oliver Elphick <olly@lfix.co.uk>)
Responses Re: Conactenating text with null values
List 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


pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: TSearch2: Problems with compound words and stop words
Next
From: Antony Paul
Date:
Subject: Characters used for pattern matching with like