VisitsManagement

SELECT s.id, c.Cliente, e.date_time login, is_new, s.date_time last_activity, a.platform, a.browser, a.version FROM user_session s JOIN visit_user e ON s.visit_user_id = e.id JOIN visit_access c ON e.access_id = c.id JOIN visit_agent a ON c.agent_id = a.id JOIN visit v ON a.visit_id = v.id JOIN account.user u ON e.user_id = u.id JOIN vn2008.Clientes c ON e.user_id = c.Id_cliente ORDER BY last_activity DESC
SELECT browser ,MIN(CAST(version AS DECIMAL(4,1))) min_version ,MAX(CAST(version AS DECIMAL(4,1))) max_version ,MAX(e.date_time) last_visit ,COUNT(DISTINCT c.id) visits ,SUM(is_new) new_visits FROM visit_user e JOIN visit_access c ON e.access_id = c.id JOIN visit_agent a ON c.agent_id = a.id JOIN visit v ON a.visit_id = v.id WHERE e.date_time BETWEEN TIMESTAMP(#from,'00:00:00') AND TIMESTAMP(#to,'23:59:59') GROUP BY browser ORDER BY visits DESC