Unix Technical Forum

Subquery to lsit

This is a discussion on Subquery to lsit within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hi all, ist there a comfortable way to turn a subquery that contains multiple values into a list? Example: ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 12:20 PM
Matthias Langbein
 
Posts: n/a
Default Subquery to lsit

Hi all,

ist there a comfortable way to turn a subquery that contains multiple
values into a list?

Example:

Table A:
ID - Name
-------------
1 - Bart
2 - Lisa
3 - Homer
4 - Marge


Table B:
User - Login
--------------
1 - 12:34
2 - 13:41
3 - 14:00
1 - 15:12
4 - 09:14
2 - 17:12

Query: something like
SELECT Name, (Select List(Login) from B where User=ID)
FROM A

Result:
Bart - 12:34, 15:12
Lisa - 13:41, 17:12
Homer - 14:00
Marge - 09:14

Is there something way I know would be to define a function that
receives the ID as parameter and returns the Logins as string, but I
wonderes whether there is a generic function or one of you knows how
to create one.

THX, Langi
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 12:21 PM
DA Morgan
 
Posts: n/a
Default Re: Subquery to lsit

Matthias Langbein wrote:
> Hi all,
>
> ist there a comfortable way to turn a subquery that contains multiple
> values into a list?
>
> Example:
>
> Table A:
> ID - Name
> -------------
> 1 - Bart
> 2 - Lisa
> 3 - Homer
> 4 - Marge
>
>
> Table B:
> User - Login
> --------------
> 1 - 12:34
> 2 - 13:41
> 3 - 14:00
> 1 - 15:12
> 4 - 09:14
> 2 - 17:12
>
> Query: something like
> SELECT Name, (Select List(Login) from B where User=ID)
> FROM A
>
> Result:
> Bart - 12:34, 15:12
> Lisa - 13:41, 17:12
> Homer - 14:00
> Marge - 09:14
>
> Is there something way I know would be to define a function that
> receives the ID as parameter and returns the Logins as string, but I
> wonderes whether there is a generic function or one of you knows how
> to create one.
>
> THX, Langi


www.psoug.org
click on Morgan's Library
click on Conditions
scroll down to "Complex IN Demo"
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:02 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com