This is my table, for this table how to write a ParentChild hierarchy in SQL
Table : Create table Emp(
ID int, --------------------> Child
NatIDNumber int,
LoginID varchar(50),
OrgLevel int, -------------> Parent
JTitle varchar(50),
DOB date
Gender nchar(1)
)
ID | NatIDnumber | LoginID | OrgLevel | JTitle | DOB | Gender |
1 | 2958472 | xxxx1 | 0 | Chief | 1963-03-02 | M |
2 | 2457979 | xxxx2 | 1 | Vice President | 1965-09-01 | F |
3 | 5096471 | xxxx3 | 2 | Engineering | 1968-12-13 | M |
4 | 1124578 | xxxx4 | 3 | Senior Tool | 1969-01-23 | M |
5 | 6952569 | xxxx5 | 3 | Design Eng | 1946-10-29 | F |
6 | 9983206 | xxxx6 | 3 | Design Eng | 1953-04-11 | M |
7 | 1349691 | xxxx7 | 3 | Research | 1981-03-27 | M |