Click to See Complete Forum and Search --> : Help with SQL query!


Nahed
02-26-2003, 09:15 AM
Hope anyone can help me here.
This is an example situation:

Table PetOwner

Peter Cat
Peter Dog

This is the table that i want to generate a query from. But i want the query to return results in this order if i wanted to find what pets Peter owned:

Generated results from SQL query

Peter Cat Dog

I.e. Instead of 2 records returned I want a single record returned with all pets associated with Peter returned in columns and not as individual rows.

Can anyone help this poor chap here?

nandu
02-26-2003, 12:26 PM
Guess you want a CROSS TAB report. I don't know if Oracle 9i has incorporated any feature. The best bet for you is to traverse a
PL/SQL cursor and do it your self as functions can return a value or valueset as you wish !


Cheers
Nandu

Nahed
02-26-2003, 12:43 PM
Thanks for the reply.
I can achieve this applying PL/SQL but i was trying to avoid taking that route. If any functions exist within SQL so that just a SQL query can achieve a horizontal resultset would be ideal.

Thanks.