Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread Andrus
David, Thank you. Whether you can write a sufficient function with 8.1 features I do not know. You main issue is you need to be able to output multiple records from a single input record and doing so before 8.4 seems problematic since functions like substring cannot do that. comment field c

Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread David Johnston
On Nov 24, 2011, at 15:40, "Andrus Moor" wrote: > Harald, > > Thank you. > >> The query > >> SELECT id, a[1] AS name, a[2] AS percent >> FROM ( SELECT id, regexp_split_to_array(regexp_split_to_table(comment, ', >> *'), '\W+') AS a >> FROM project ) AS dummy > >> should work un every halfway

Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread Andrus Moor
Harald, Thank you. The query SELECT id, a[1] AS name, a[2] AS percent FROM ( SELECT id, regexp_split_to_array(regexp_split_to_table(comment, ', *'), '\W+') AS a FROM project ) AS dummy should work un every halfway recent PostgreSQL version - dunno about 8.1. I tried it but got error

Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread Harald Fuchs
"Andrus" writes: > David, >>Regular Expressions are your friend here. If you do not know them you > should learn them; though if you ask nicely someone may just provide you > the solution you need. >>Split-to-array and unnest may work as well. > > Thank you very much. I dona**t know regexps. >

Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread Andrus
David, >Regular Expressions are your friend here. If you do not know them you should >learn them; though if you ask nicely someone may just provide you the solution >you need. >Split-to-array and unnest may work as well. Thank you very much. I don’t know regexps. Can you provide example, please

Re: [GENERAL] How to get normalized data from tekst column

2011-11-24 Thread David Johnston
On Nov 24, 2011, at 8:47, "Andrus" wrote: > Project table contains salesman names and percents as shown > below. Single comment column contains 1-2 salesman names and commissions. > How select normalized data from this table ? > > Andrus. > > CREATE TABLE project ( > id char(10) primary key,

[GENERAL] How to get normalized data from tekst column

2011-11-24 Thread Andrus
Project table contains salesman names and percents as shown below. Single comment column contains 1-2 salesman names and commissions. How select normalized data from this table ? Andrus. CREATE TABLE project ( id char(10) primary key, comment char(254) ); insert into test values ('2010-12', 'Aa