You could use the Only() aggregation on fields ITEM, DATA and STORE in a resident load grouping by DOCNUM and FLAG_SDATA, but I think you should why this table was created like this in the first place. Maybe you just have to replace a concatenation with a join, thus avoiding the question of how to combine these multiple rows.