create table sort_test
(INTCATEGORYID int,
name varchar(10),
parentid int)
insert into sort_test values (1,'ASD',1)
insert into sort_test values (2,'EFD',1)
insert into sort_test values (5,'FGH',1)
insert into sort_test values (6,'JKL',2)
insert into sort_test values (8,'VBN',3)
insert into sort_test values (9,'FG',3)
insert into sort_test values (0,'VB',3)
Select INTCATEGORYID ,NAME ,PARENTID
from sort_test
order by
parentid,
case when parentid = 1
then INTCATEGORYID * -1
else
INTCATEGORYID
end