select count( t2.coddoc), t2.coddoc from stkdocs t, ( select tt.coddoc from stkdocs tt where tt.coddoc < 120000 group by tt.coddoc) t2 where t2.coddoc > t.coddoc and t.coddoc < 120000 group by t2.coddoc order by 1