• Based on what you have and the output that you have shown, the following should give you what you're looking for...

    SELECT

    m1.ParentID AS Account_ID,

    STUFF((

    SELECT ', ' + CAST(m2.ChildID AS VARCHAR(8))

    FROM #mytable m2

    WHERE m1.ParentID = m2.ParentID

    FOR XML PATH('')), 1, 2, '') AS ChildList

    FROM

    #mytable m1

    GROUP BY

    m1.ParentID

    Here is the output...

    Account_ID ChildList

    ----------- ------------

    1 1, 2, 3

    2 3, 5

    5 1

    HTH,

    Jason