select * from
(
select aa.person_id,aa.ip,aa.c,row_number() over(partition by aa.person_id order by aa.c desc) rn
from
(select t.person_id,t.ip,count(*) c
from log_book t
where t.logtype=1
group by t.person_id,t.ip
order by t.person_id,count(*) desc) aa
)
where rn > 1