I believe my title says it, I have a mySQL database that contains the following columns:
id -- timestamp
1 -- 2014-09-15 10:22:40
1 -- 2014-09-15 10:13:30
1 -- 2014-09-14 10:11:10
2 -- 2014-09-14 10:20:40
2 -- 2014-09-14 10:19:30
3 -- 2014-09-13 10:17:10
How can I show the visits made by user_id per day? Meaning:
id 1 2014-09-15 visited 2 times
id 1 2014-09-14 visited 1 times
id 2 2014-09-14 visited 2 times
id 3 2014-09-13 visited 2 times
You can do so by getting date value from timestamp
column and group by id and date value
select id,
date(`timestamp`) per_day,
count(*)
from test
group by id,per_day
order by id,per_day desc
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments