From: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | need substring based on delimiter |
Date: | 2012-08-23 21:30:33 |
Message-ID: | 0AD01C53605506449BA127FB8B99E5E11802C11E@FMSMSX105.amr.corp.intel.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi:
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".
Tried splitting this to an array (precursor to appending elements 1,2,3), but failed to be able to reference the elements returned...
stdb_a0=# select string_to_array('aaa,bbb,ccc,ddd,eee,fff,ggg',',');
string_to_array
-------------------------------
{aaa,bbb,ccc,ddd,eee,fff,ggg}
(1 row)
stdb_a0=# select string_to_array('aaa,bbb,ccc,ddd,eee,fff,ggg',',')[1];
ERROR: syntax error at or near "["
If there was a way "position" would return the pos of the 3rd comma, I could use sustring. But I don't think it can :-(
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Swingley | 2012-08-23 21:39:11 | Re: Statistical aggregates with intervals |
Previous Message | Michael Clark | 2012-08-23 19:42:09 | Re: Problems with timestamp with time zone and old dates? |