• This is Barry's original case method applied to your table structure.

    SELECT *

    FROM #Temp

    ORDER BY (CASE WHEN ParentID = '1' THEN 0 ELSE 1 END), ParentId

    Notice the way Chris posted your table structure and sample data. Please use this format in future posts, as it makes things much easier for us to deal with. For more instructions on how to do this, please see the link in either of our signatures. Thanks for the inserts Chris. 😎

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]