• I think this does what you need.

    --test table

    CREATE TABLE OrderTest

    (id INT,

    parentid INT NULL)

    --test data

    INSERT INTO OrderTest

    VALUES

    (1, NULL),

    (2, NULL),

    (3, NULL),

    (4, 1),

    (5, 1),

    (6, 2),

    (7, 2),

    (8, 3),

    (9, 3)

    --query

    SELECT *

    FROM OrderTest

    ORDER BY COALESCE(ParentId,Id), Id

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning