ankit ankit - 1 year ago 80
MySQL Question

Find number of users count in a day who visit the url

I need a query to fetch 'number of different users count' in a day who visit the url. This is structure of my table
enter image description here

And i try this query

SELECT DISTINCT `userid`,`url`, FROM_UNIXTIME(`time`,'%Y-%m-%d') as date,count(`userid`) as usercount FROM `mdl_log` GROUP BY FROM_UNIXTIME(`time`,'%Y-%m-%d')

but it not work. Please help me to correct this query.

Answer Source

use disinct and count together

SELECT count(DISTINCT `userid`) as usercount,`url`, FROM_UNIXTIME(`time`,'%Y-%m-%d') as date FROM `mdl_log` GROUP BY FROM_UNIXTIME(`time`,'%Y-%m-%d')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download