Re: String reverse funtion?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: John Meyer <johnmeyer(at)pueblocomputing(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: String reverse funtion?
Date: 2013-10-09 18:07:18
Message-ID: CAFj8pRCu+mX3OcRmqev6Rpb3h6NjuJ=vbQ6+LtZAyxAhdCNpfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2013/10/9 John Meyer <johnmeyer(at)pueblocomputing(dot)com>

> On 10/9/2013 11:52 AM, David Johnston wrote:
>
>> ginkgo36 wrote
>>
>>> Hello everyone
>>> I have to reverse a string like EA;BX;CA to CA;BX;EA. or EA,BX,CA to
>>> CA,BX,EA
>>> Is there any function to do this?
>>>
>>> Thanks all!
>>>
>> No. You will have to write your own.
>>
>> David J.
>>
>>
>>
>
> Based upon the example, it's probably very easy to use a split/explode in
> your language of choice (VB.NET, perl, python, etc).

or SQL

select string_agg(u, ';' order by r desc)
from (select row_number() over () r, u
from unnest(string_to_array('EA;BX;CA',';')) u) x;
string_agg
────────────
CA;BX;EA
(1 row)

Regards

Pavel

>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/**mailpref/pgsql-general<http://www.postgresql.org/mailpref/pgsql-general>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Meyer 2013-10-09 18:09:19 Re: String reverse funtion?
Previous Message John Meyer 2013-10-09 17:57:34 Re: String reverse funtion?