SELECT *,( rownumber - 1 ) rownumber2 from (select *,CEIL( ( @rowNum := @rowNum + 1 ) / 3 ) AS rownumber,'' AS kk from hl4pl_material_preparation_detail a,( SELECT @rowNum := 0 ) b where return_master_id=959) c