Обсуждение: Re: String reverse funtion?
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. -- View this message in context: http://postgresql.1045698.n5.nabble.com/String-reverse-funtion-tp5773871p5773887.html Sent from the PostgreSQL - general mailing list archive at Nabble.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).
2013/10/9 John Meyer <johnmeyer@pueblocomputing.com>
On 10/9/2013 11:52 AM, David Johnston wrote:Based upon the example, it's probably very easy to use a split/explode in your language of choice (VB.NET, perl, python, etc).ginkgo36 wroteHello everyoneNo. You will have to write your own.
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!
David J.
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)
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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
That works too. Point being ginkgo36 has his solution.
On 10/9/2013 12:07 PM, Pavel Stehule wrote:
On 10/9/2013 12:07 PM, Pavel Stehule wrote:
2013/10/9 John Meyer <johnmeyer@pueblocomputing.com>On 10/9/2013 11:52 AM, David Johnston wrote:Based upon the example, it's probably very easy to use a split/explode in your language of choice (VB.NET, perl, python, etc).ginkgo36 wroteHello everyoneNo. You will have to write your own.
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!
David J.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)RegardsPavel
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Thanks alot everyone,
Actually, I just start learning about Programming language. So, each your
solution is a good suggestion for me to learning. Thanks so much.
Please help me one User-defined Functions to solves this when my data like
this:
EA;BX;CA
CA;EA
BX;EA
And when run UDFs, output is:
CA;BX;EA
EA;CA
EA;BX
One again, thanks so much
Pavel Stehule wrote
>> 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@
> )
>> To make changes to your subscription:
>> http://www.postgresql.org/**mailpref/pgsql-general<http://www.postgresql.org/mailpref/pgsql-general>
>>
--
View this message in context: http://postgresql.1045698.n5.nabble.com/String-reverse-funtion-tp5773871p5773950.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.