CREATE TABLE #Organizations (ID INT, Number INT, Name varchar(30), SuperiorOrganizationID INT) INSERT INTO #Organizations VALUES (1, 1, 'Dell', NULL), (2, 2, 'HP', NULL), (3, 100, 'IBM World', NULL), (4, 150, 'IBM Europe', 3), (5, 159, 'IBM Germany', 4) Select Number, Name, TopMostOrganizationID = 'TO SOLVE' From #Organizations DROP TABLE #Organizations
I need to solve the column TopMostOrganizationID. The result should be:
1, 'Dell', 1 2, 'HP', 2 100, 'IBM World', 3 150, 'IBM Europe', 3 159, 'IBM Germany', 3
Any idea?
... Podlesnick ...