A quick solution if it is ok for you. > SELECT LPAD(' ', 2*LEVEL)||ID FROM account_Test 2 CONNECT BY PRIOR ID=parent_ID; LPAD('',2*LEVEL)||ID --------------------------------------------------------------- 100 200 300 201 101 102 200 300 201 300 1 100 200 300 201 101 102 Yasin Baskan KOCBANK IT / System Support +90216 4540600 Ext: 4681 Get Firefox! -----Original Message----- From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Sandeep Dubey Sent: Friday, August 26, 2005 5:24 PM To: oracle-l@xxxxxxxxxxxxx Subject: SQL query Hi, Can someone help me with the sql query. It is similar to emp_id and manager_id. create table account_test(id number, parent_id number); insert into account_test values(1,null); insert into account_test values(100,1); insert into account_test values(101,1); insert into account_test values(102,1); insert into account_test values(200,100); insert into account_test values(201,100); insert into account_test values(300,200); Here id 1 is parent of 100, 101 and 102 100 is parent of 200 and 201 300 is child of 200 I need to write a query that id 1 can see all records. 100 can see it's and all its child and sub-child i.e. 100, 200, 201 and 300 200 can get 200 and 300. It will be N-tier parent-child. Thanks Sandeep -- //www.freelists.org/webpage/oracle-l Bu mesaj ve onunla iletilen tum ekler gonderildigi kisi ya da kuruma ozel ve Bankalar Kanunu geregince, gizlilik yukumlulugu tasiyor olabilir. Bu mesaj, hicbir sekilde, herhangi bir amac icin cogaltilamaz, yayinlanamaz ve para karsiligi satilamaz; mesajin yetkili alicisi veya alicisina iletmekten sorumlu kisi degilseniz, mesaj icerigini ya da eklerini kopyalamayiniz, yayinlamayiniz, baska kisilere yonlendirmeyiniz ve mesaji gonderen kisiyi derhal uyararak bu mesaji siliniz. Bu mesajin iceriginde ya da eklerinde yer alan bilgilerin dogrulugu, butunlugu ve guncelligi Bankamiz tarafindan garanti edilmemektedir ve bilinen viruslere karsi kontrolleri yapilmis olarak yollanan mesajin sisteminizde yaratabilecegi zararlardan Bankamiz sorumlu tutulamaz. This message and the files attached to it are under the privacy liability in accordance with the Banking Law and confidential to the use of the individual or entity to whom they are addressed. This message cannot be copied, disclosed or sold monetary consideration for any purpose. If you are not the intended recipient of this message, you should not copy, distribute, disclose or forward the information that exists in the content and in the attachments of this message; please notify the sender immediately and delete all copies of this message. Our Bank does not warrant the accuracy, integrity and currency of the information transmitted with this message. This message has been detected for all known computer viruses thence our Bank is not liable for the occurrence of any system corruption caused by this message -- //www.freelists.org/webpage/oracle-l