• your query seems ok and working fine

    may be you are selecting LEFT(127.0.0.1,len(127.0.0.1)-charindex('.',reverse(([Ip])))) which may leads you to confusion

    you can try putting ip in select and find where's the problem

    select LEFT(127.0.0.1,len(127.0.0.1)-charindex('.',reverse(([Ip])))),ip

    from @t

    group by 127.0.0.1

    having count (127.0.0.1)>1

    order by (127.0.0.1) desc

    or else post some sample data in which you are facing problem.