select
s.name `Store View`,
date_format(u.visit_time, "%Y-%m") Period,
count(distinct vi.remote_addr) `Unique Visits`,
< count where vi.http_user_agent regexp 'bot|spider|w3c|validat|crawl|monitor|php' > `Visits from Bots`,
count(1) `Total Visits`
from log_url u
inner join log_visitor_info vi
on vi.visitor_id = u.visitor_id
inner join log_url_info i
on i.url_id = u.url_id
inner join log_visitor v
on v.visitor_id = vi.visitor_id
inner join core_store s
on s.store_id = v.store_id