Re: Removing Last field from CSV string

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Removing Last field from CSV string
Date: 2020-05-16 16:53:17
Message-ID: 8a48e8dc-9740-c444-240f-02d1e9f84174@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/16/20 9:31 AM, PALAYRET Jacques wrote:
> Hello,
>
> Perhaps, a statement like :
>    substring(theString, 1, length(theString)-position(',' IN
> reverse(theString)))
>
> with theString   'Class V,Class VI,Class VII,Competitive Exam,Class
> VIII*,Class' for example.

That's cool. I did a little fiddling with above:

SELECT
substring(
left('Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class
X,Class XI,Class IX,Class XII', 60), 1, length(
left('Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class
X,Class XI,Class IX,Class XII', 60)) - position(',' IN reverse(
left('Class V,Class VI,Class VII,Competitive Exam,Class VIII,Class
X,Class XI,Class IX,Class XII', 60))))

substring
--------------------------------------------------------
Class V,Class VI,Class VII,Competitive Exam,Class VIII

> Regards
> ----- Météo-France -----
> PALAYRET JACQUES
> DCSC/MBD
> jacques(dot)palayret(at)meteo(dot)fr
> Fixe : +33 561078319

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Don Seiler 2020-05-16 17:19:13 template0 needing vacuum freeze?
Previous Message PALAYRET Jacques 2020-05-16 16:31:30 Re: Removing Last field from CSV string