Adding a running count of distinct values in MySQL 5.7
SELECT t1.run_name, hardware_used, COUNT(*) times_used
FROM hardware t1
JOIN hardware t2 USING (hardware_used)
WHERE t1.run_name &gt;= t2.run_name
GROUP BY t1.run_name, hardware_used
ORDER BY t1.run_name;


fiddle