0
I have this query in Mysql to check the unique accesses to a system of mine:
SELECT COUNT(DISTINCT id_usuario) AS total, dia FROM acesso
WHERE (dia BETWEEN '2018-01-21' AND '2019-01-21')
GROUP BY dia
ORDER BY dia ASC
And the way I see it, he’s listing the unique access to the system.
My doubt: the customer asked to check the weekly single accesses, IE, if the user access at least 1 only time during the period of 1 week, would already count his access, how to do? I tried this way, but the total ends up giving less than the only daily access:
SELECT COUNT(DISTINCT id_usuario) AS total, dia FROM acesso
WHERE (dia BETWEEN '2018-01-21' AND '2019-01-21')
GROUP BY WEEK(dia)
ORDER BY dia ASC
What version of
MySQL
?– Sorack
Version of the database client: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
– caiocafardo