pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
retrieving specific info. from one column and locating it in another
2+ messages / 2 participants
[nested] [flat]

* retrieving specific info. from one column and locating it in another
@ 2002-11-21 14:11 MARC BEDOIS <mbedois@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: MARC BEDOIS @ 2002-11-21 14:11 UTC (permalink / raw)
  To: pgsql-sql

I'm trying to retrieve some info from one column and
put it in another.  I have a column that has a bunch
of information in it called 'Route'.  I don't need to
show all of that information.  Instead I need divide
that single column into two seperate columns called
'Sender' and 'Receiver'.  How do I divide this
information up into these two columns.  I know of
methods called charindex and patindex.  I need to do
something like that but instead of returning the
position of the info, to just return the selected
info.    
Ex)  I have a column named Route....with info in it
similar to 'UPS NS  Ground'
       How do I create a second column called
'Delivery' and pull only the 'NS' out of the Route
column and put it into the 'Reciever' column?
       Similarly how would I pull just the UPS part
out of Route and put it into 'Sender'?


thanks,
Marc

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: retrieving specific info. from one column and locating it in another
@ 2002-11-28 16:14 Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Christoph Haller @ 2002-11-28 16:14 UTC (permalink / raw)
  To: mbedois@yahoo.com; +Cc: pgsql-sql

>
> I'm trying to retrieve some info from one column and
> put it in another.  I have a column that has a bunch
> of information in it called 'Route'.  I don't need to
> show all of that information.  Instead I need divide
> that single column into two seperate columns called
> 'Sender' and 'Receiver'.  How do I divide this
> information up into these two columns.  I know of
> methods called charindex and patindex.  I need to do
> something like that but instead of returning the
> position of the info, to just return the selected
> info.
> Ex)  I have a column named Route....with info in it
> similar to 'UPS NS  Ground'
>        How do I create a second column called
> 'Delivery' and pull only the 'NS' out of the Route
> column and put it into the 'Reciever' column?
>        Similarly how would I pull just the UPS part
> out of Route and put it into 'Sender'?
>

Marc,

I've seen some tricky stuff to split column values yesterday on the
list.
It was sent by Peter Childs Subject  Re: [SQL] Question on SQL and
pg_-tables.

He found something like a split.
Adapted to your needs it would result in something similar to (supposed
blanks are your separators)

SELECT SUBSTRING(route,1,POSITION(' ' IN route)-1) AS ups,
SUBSTRING(route,POSITION(' ' IN route)+1,POSITION(' ' IN
SUBSTRING(route,POSITION(' ' in ROUTE)+1))) AS ns
FROM ...

Hope this helps.

Regards, Christoph






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-11-28 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-21 14:11 retrieving specific info. from one column and locating it in another MARC BEDOIS <mbedois@yahoo.com>
2002-11-28 16:14 Re: retrieving specific info. from one column and locating it in another Christoph Haller <ch@rodos.fzk.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox