SELECT t1.DOC, t1.TYPE, COUNT(*) AS [Ino Seq] FROM MyData AS t1 INNER JOIN MyData AS t2 ON t2.DOC = t1.DOC AND t2.Ino <= t1.Ino GROUP BY t1.DOC, t1.TYPE ORDER BY 1, 3