Home » SQL & PL/SQL » SQL & PL/SQL » Tree structure query
Tree structure query [message #340248] Tue, 12 August 2008 01:48 Go to next message
arksjd
Messages: 13
Registered: November 2007
Junior Member

Hi

I have table test9.


SELECT *  FROM test9;

The output is as below

        l1code l1code_desc  l2code       l2code_desc        
  
1	BANK	 BANKS	      BNK	 SMALL BNK
2	BANK	 BANKS	      NC9	 NATCOM NINE
3	CORP	 CORPORATE    CFI	 CFI DESC
4	CORP	 CORPORATE    OFI	 OFI DESC

I want the output in a hierarchy structure as given below

L1CODE  L2CODE

BANK    BNK
        NC9
CORP    CFI
        OFI




How do I achieve the above result. I tried using hierarchical query but could not get the same.

kindly help me.

thanks
Raj.
Re: Tree structure query [message #340250 is a reply to message #340248] Tue, 12 August 2008 01:57 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is not a hierarchy, you just want to not repeat the l1code value.

This has been asked many times and not longer than last week, search for "break".

Regards
Michel
Re: Tree structure query [message #340253 is a reply to message #340248] Tue, 12 August 2008 02:02 Go to previous message
msmallya
Messages: 66
Registered: March 2008
Location: AHMEDABAD, GUJARAT
Member
Hi,

Use order by clause (order by l1code, l2code).

Before issuing query also set

break on l1code;
break on l2code;

Regards,

MSMallya
Previous Topic: How to fatch the data from previous row
Next Topic: How to check space at varchar2 column
Goto Forum:
  


Current Time: Fri Dec 09 09:42:00 CST 2016

Total time taken to generate the page: 0.10746 seconds