select top 1 c1.code_number as c1, c2.code_number as c2, min(c2.code_number - c1.code_number) as delta
from code as c1
join code as c2
on c2.code_number > c1.code_number
group by c1.code_number, c2.code_number
having min(c2.code_number - c1.code_number) > 0
order by 3