Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Return multiple-rowed subqueries as additional columns
Graeme D wrote:
> I have a database of support tickets I am querying. there is a main
> table and a status table which can have 0 or more rows per associated
> ticket.
>
> Is there a way for me to return multiple rows of data from the status
> table into one resulting row while also querying the main ticket?
>
> Here is what I have so far:
>
> SELECT Ticket, Misc1, Misc2,
> (SELECT TOWKGRPNAME FROM ACTREFEROUT RO WHERE Ticket='xxyyzz') rog1,
> FROM Ticket WHERE TKTNUM='xxyyzz'
>
> What I want is to somehow return all rows of the subquery as diff
> columns in the main query, like so:
>
> Ticket, Misc 1, Misc 2, rog1, rog2, rog3
>
> is this even possible?
>
> Thanks
> Graeme
How wide is a piece of paper?
It sounds like a bad idea but if you want to do it look at DECODE and
CASE and how to use them create columns and perform cross-tabulations.
http://www.psoug.org
click on Morgan's Library
click on DECODE
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond)Received on Thu Jan 13 2005 - 16:25:45 CST
![]() |
![]() |