• try this

    select count(id)

    from tablename WITH(nolock)

    where gpstime between A and B

    and id=123;