SQL Command combining rows from a field
===

I am trying to combine rows from one table with my query. I pulled this code off here I believe. This almost fits my needs but it is grouping the serial numbers off of SOPartsUsed but I need it to group based off tblServiceOrders.ProjectKeyID. Any help would be greatly appreciated I don't know much about SQL. I will leave a more detailed explanation of what I am trying to accomplish below. 

    SELECT        
    p1.ItemID,p1.ItemDescription, SerialNumbers AS SerialNumber 
    FROM            
    tblSOPartsUsed p1 INNER JOIN
    tblServiceOrders p2 ON p1.SONumber = p2.SONumber
        CROSS APPLY
           (SELECT        
            stuff
               ((SELECT ',' + p3.SerialNumber
                 FROM tblSerialNumbers p3
                 WHERE p3.FKSOPartsUsed = p1.SOPartsUsedKeyID
                 ORDER BY SerialNumber FOR XML PATH(''), TYPE ).value('.', 'varchar(max)'), 1, 1, '')
	    ) D (SerialNumbers)
     WHERE        (p1.QuantityFilled > 0) AND (p2.ProjectKeyID = 385)
     GROUP BY p1.ItemDescription, p1.ItemID, SerialNumbers, p2.ProjectKeyID
     ORDER BY p1.ItemID


I have a table with serial numbers a table with parts used on a service order and a service order table.

tblSerialNumbers -> tblSOPartsUsed -> tblServiceOrders 

I am trying to group serial numbers and item id's by ProjectKeyID found in tblServiceOrders. Right now the query above works but it is grouping ItemID's on the tblSOPartsUsed and want to group on ProjectKeyID.

Thanks for any help.