I have to agree with hobodave that it would probably be better to rank as you fetch instead of as you insert, so you should reconsider if you really want to do this. But if this is actually what you need, it can be done as you requested like this:
INSERT INTO Table1 (val1, val2, cnt)
SELECT val1, val2, @rn := @rn + 1 AS rn
FROM (
SELECT val1, val2, MAX(cnt) AS cnt
FROM Table2
WHERE val1 = 1
GROUP BY val2
ORDER BY cnt DESC
LIMIT 10
) AS T1, (SELECT @rn := 0) AS vars;
SELECT *
FROM Table1
ORDER BY cnt;
Result:
1, 4, 1
1, 2, 2
1, 7, 3
1, 6, 4
Test data:
CREATE TABLE Table1 (val1 INT NOT NULL, val2 INT NOT NULL, cnt INT NOT NULL);
CREATE TABLE Table2 (val1 INT NOT NULL, val2 INT NOT NULL, cnt INT NOT NULL);
INSERT INTO Table2 (val1, val2, cnt) VALUES
(1, 2, 3),
(1, 4, 5),
(1, 4, 2),
(1, 6, 0),
(1, 7, 1),
(1, 7, 2),
(2, 1, 1);