25 lines
785 B
MySQL
25 lines
785 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`visit_listByBrowser`(vFrom DATE, vTo DATE)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Lists visits grouped by browser.
|
||
|
*
|
||
|
* @param vFrom The from date
|
||
|
* @param vTo The to date
|
||
|
* @select The list of visits
|
||
|
*/
|
||
|
SELECT browser,
|
||
|
MIN(CAST(version AS DECIMAL(4, 1))) minVersion,
|
||
|
MAX(CAST(version AS DECIMAL(4, 1))) maxVersion,
|
||
|
MAX(c.stamp) lastVisit,
|
||
|
COUNT(DISTINCT c.id) visits,
|
||
|
SUM(a.firstAccessFk = c.id AND v.firstAgentFk = a.id) newVisits
|
||
|
FROM visitUser e
|
||
|
JOIN visitAccess c ON c.id = e.accessFk
|
||
|
JOIN visitAgent a ON a.id = c.agentFk
|
||
|
JOIN visit v ON v.id = a.visitFk
|
||
|
WHERE c.stamp BETWEEN TIMESTAMP(vFrom,'00:00:00') AND TIMESTAMP(vTo,'23:59:59')
|
||
|
GROUP BY browser ORDER BY visits DESC;
|
||
|
END$$
|
||
|
DELIMITER ;
|