dbTalk Databases Forums  

Complex Select

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Complex Select in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
The Magnet
 
Posts: n/a

Default Complex Select - 05-19-2010 , 05:55 PM






I've modified this select statement so that it will take a column from
multiple rows and concatenate them and delimit them. The value
returned is this:

2:Media","1:Pages","5:Trading","3:Links

However, using the query below, I cannot find a way to get the
beginning and ending quotes. Help?


v_select := '
WITH data AS (
SELECT user_id, username, first_name, last_name, email,
u.service_id || ''' || v_colon || ''' || service_name services,
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY user_id) rn,
COUNT(*) OVER () cnt
FROM commentary.services s, commentary.user_services u, customer
c, customer_account ca
WHERE c.customer_id = ca.customer_id
AND c.customer_id = u.user_id
AND LOWER(c.email) = ''' || p_email || '''
AND ca.password = ''' || p_password || '''
AND u.service_id = s.service_id)
SELECT user_id, username, first_name, last_name, email,
LTRIM(SYS_CONNECT_BY_PATH(services,''","''),''","' ') services
FROM data
WHERE rn = cnt
START WITH rn = 1
CONNECT BY PRIOR user_id = user_id AND PRIOR rn = rn-1
ORDER BY user_id';

Reply With Quote
  #2  
Old   
Jens Kammler
 
Posts: n/a

Default Re: Complex Select - 05-20-2010 , 01:07 PM






"The Magnet" <art (AT) unsu (DOT) com> schrieb :
Quote:
I've modified this select statement so that it will take a column from
multiple rows and concatenate them and delimit them. The value
returned is this:

2:Media","1:Pages","5:Trading","3:Links

However, using the query below, I cannot find a way to get the
beginning and ending quotes. Help?

Untestet, what about?


'"' || LTRIM(SYS_CONNECT_BY_PATH(services,''","''),''","' ') || '"'
services

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.