Обратите внимание на следующее:
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
(id SERIAL PRIMARY KEY
,name VARCHAR(20) NOT NULL
,age INT NOT NULL
,hobby VARCHAR(20) NOT NULL
);
INSERT INTO my_table (name,age,hobby) VALUES
('Mark',21,'Soccer'),
('Mark',21,'Football'),
('pizzipizzi',7,'cronchcronch'),
('Steve',23,'Basketball'),
('Steve',23,'Coding'),
('Steve',23,'Soccer');
SELECT x.*
, COUNT(y.id)-1 counter
FROM my_table x
JOIN my_table y
ON y.name = x.name
AND y.age = x.age
AND y.id <= x.id
GROUP
BY x.id;
+----+------------+-----+--------------+---------+
| id | name | age | hobby | counter |
+----+------------+-----+--------------+---------+
| 1 | Mark | 21 | Soccer | 0 |
| 2 | Mark | 21 | Football | 1 |
| 3 | pizzipizzi | 7 | cronchcronch | 0 |
| 4 | Steve | 23 | Basketball | 0 |
| 5 | Steve | 23 | Coding | 1 |
| 6 | Steve | 23 | Soccer | 2 |
+----+------------+-----+--------------+---------+
Обратите внимание, что в MySQL 8.0+ у вас есть больше вариантов