Il semble que vous souhaitiez simplement CONCAT()
les valeurs ensemble :
select data, group_row_number,
concat(data, cast(group_row_number as char)) as num,
overall_row_num
from
(
select data,
@num := if(@data = `data`, @num + 1, 1) as group_row_number,
@data := `data` as dummy, overall_row_num
from
(
select data, @rn:[email protected]+1 overall_row_num
from yourtable, (SELECT @rn:=0) r
) x
order by data, overall_row_num
) x
order by overall_row_num
Voir SQL Fiddle avec démo