I have a database table which holds each user\'s checkins in cities. I need to know how many days a user has been in a city, and then, how many visits a user has made to a c
for a first sub-task:
select count(*) from ( select TO_DAYS(p.d) from p group by TO_DAYS(p.d) ) t