From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: need substring based on delimiter |
Date: | 2012-08-23 21:58:52 |
Message-ID: | 5036A79C.8080305@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 08/23/2012 02:30 PM, Gauthier, Dave wrote:
> I want to create a string from the first 3 elements of a csv (for
> example). The csv is longer than 3 elements. Example...
>
> aaa,bbb,ccc,ddd,eee,fff,ggg
>
> I want the string "aaa,bbb,ccc".
select array_to_string
(
(
string_to_array
(
'aaa,bbb,ccc,ddd,eee,fff,ggg',','
)
)[1:3],','
);
array_to_string
-----------------
aaa,bbb,ccc
(1 row)
HTH,
Joe
--
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
From | Date | Subject | |
---|---|---|---|
Next Message | Ondrej Ivanič | 2012-08-23 22:43:53 | Re: Statistical aggregates with intervals |
Previous Message | Christopher Swingley | 2012-08-23 21:39:11 | Re: Statistical aggregates with intervals |