SQLTeam.com | Weblogs | Forums

Query data from Single Table - Kindly Help


#1

Hello SQL Experts/Guru,

I am little new to SQL and need some help.
I have a following table -

Data Table -

ID Parent ID ClassCode
2122 2122 BSc
2123 2124 MSc
2124 2234 Mtech
2125 2126 Btech
2126 2245 MBA
2245 2245 BBA

ID will be unique ,
Parent ID can be same as that of the ID or it can be the one present in ID
Class Code contain the code of the class based on ID only

I Want ID and Parent ID and respective Class Code.
Output Data to be like s following -

ID Parent ID Class Code Parent Class Code
2122 2122 BSc
2123 2124 MSc Mtech
2124 2234 Mtech
2125 2126 Btech MBA
2126 2245 MBA BBA
2245 2245 BBA

Kindly help


#2

Looks like homework to me. You need to try to build the query and post what you have, even it it doesn't work