UPDATE table1 AS t1 SET field1 = ( SELECT * FROM ( SELECT count(*) FROM table1 AS t2 WHERE t2.field2 < t1.field2 ) AS grouped )