Skip to content
Advertisement

retrieve unique visits sql not working mysql

I have this table

When a different ip enters to the site in an specific day, it insert a new row, no matter if the ip is entering again.

Whit this sql statement I retrieve all unique ip visits in my site. It works for an specific day, for example today (26/05/2020) and it grouped it by ip

Now I want to make an small daily report

count retrieves all the times a especific ip has entered during the whole day. I jut want it to count it as 1.

OUTPUT

I want to retrieve unique ip visits. not the sum of the times every ip has entered during the day.

EXPECTED RESULT

How can I fix this?

Advertisement

Answer

I think that you want aggregation and count(distinct ip).

This counts how many unique ips visited the site on each day. If you want the overall count of visits (regardless of whether the same ip visited more than once), then you can use count(*) instead.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement