Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display data horizontally from DB 1

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,537
US

I asked this question in another group, but was directed here.....

If I have data in TableA:[tt]
ProjectNumber

ABCD[/tt]

TableB:[tt]
ProjectNumber AnotherField

ABCD xyz[/tt]

As long as I have just one (or none) record in TableB, I can ask for this data:

Code:
Select ProjectNumber || ' ' || 
([blue]Select AnotherField from TableB
Where TableB.ProjectNumber = TableA.ProjectNumber[/blue]) As MyProjNo
From TableA
And I get displayed:[tt]
MyProjNo

ABCD xyz[/tt]

But I have this in TableB:[tt]
ProjectNumber AnotherField

ABCD xyz
ABCD ggg
ABCD klm
ABCD opq[/tt]

And I want to have displayed:[tt]
MyProjNo

ABCD xyz ggg klm opq[/tt]

Any ideas?

Hoping for a simple solution... :)

(Data base is Oracle)

Have fun.

---- Andy
 
You don't indicate which version of Oracle you have but if it's 9 or above and enterprise edition try my solution from this thread



If this doesn't work for you do a search on Pivot or transpose in the Oracle8,9 or 10 forums and I'm sure you'll find a solution.



In order to understand recursion, you must first understand recursion.
 

I am not going to lie to you – I have no idea how it works, I just know it works like a dream. :)

Thank you.


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top