Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concantenate SQL, need help

Kodiak_SeattleMay 14 2009 — edited May 14 2009
I have a Table where columns 8, 9, 10, 11, and 12 need to be concatenated into a single column CUST_ADDRESS. I've already added the new column to the end of the Table.

column 8 is: ADDRESS
column 9 is: ADDRESS 2
column 10 is: CITY
column 11 is: STATE
column 12 is: ZIP-CODE

ADDRESS( )ADDRESS 2( )CITY(, )STATE( )ZIP

I've done some research already and I think I found something that will work. The only problem is that I only need the 5 columns to be concatenated, there is 23 columns total in the Table. Also (this is not a big deal), but not sure if it would be possible to also use a ", " between the CITY and STATE and the rest can use a SPACE in the concatenation.

Help would be appreciated, thanks!

def Delimiter=" "

SELECT
ID,
SUBSTR(MAX(REPLACE(
SYS_CONNECT_BY_PATH(STRVAL, '/')
,'/','&Delimiter')),2) Concatenated_String

FROM (
select A.*,
row_number() OVER (Partition by ID order by ID) ROW#
from TMP_TEST A)

START WITH ROW#=1
CONNECT BY PRIOR ID=ID AND PRIOR row# = row# -1
GROUP BY ID;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2009
Added on May 14 2009
4 comments
574 views