I think you need another column in this query. How do you know that the first "1 ABC DEF" record is to be concatenated with the "2 DEF ABC" record instead of the "2 DEF PQR" record? If these are supposed to be processed in some sort of order, there has to be another column used to do this ordering for a loop to work. Or, there needs to be another column used to group like records together.