select count(id) from tabella where id<idcorrente