Предположим, что таблица имеет следующую структуру.
create table tblNode (
nodNum int not null,
nodLevel int,
nodOpen int not null,
nodSort int not null,
nodLead int not null,
nodParent int null,
-- insert other columns here(?)
constraint PK_tblNode primary key clustered (nodNum),
constraint FK_tblNode_tree foreign key (nodParent)
references tblNode(nodNum)
);
Запрос будет выглядеть примерно так.
select
nodLevel,
nodNum,
nodLead,
nodParent,
nodSort -- you may have to include this column to sort on it later
/* insert other columns here(?) */
from tblNode as childNode
inner join tblNode as parentNode on parentNode.nodNum = childNode.nodParent
where parentNode.nodOpen = 1
order by nodSort