EH! Come on lads, you both know better than that. What's with the distinct in a group by query??? Group by already returns each distinct value in the grouped column.
So, Kudose, you want to know how many distinct IPs there are, how many each day, and how many hits each has. By day or in total? No matter, boith can be done with WITH ROLLUP .
Basic hit count per day per ip
$sql = "SELECT DATE(date) AS do, ip, COUNT(hid) FROM table GROUP BY do, ip";
// PS this is mysql specific code and will not work on many other dbs
[code=php]
That will return the unique ips for each date and the hit count each has. If you just want the unique ips per date then
[code=php]
$sql = "SELECT DATE(date) AS do, COUNT(ip) FROM table GROUP BY do";
[code=php]
Now to extend it to give the running total for all dates you just add the rollup
[code=php]
[code=php]
$sql = "SELECT DATE(date) AS do, COUNT(ip) FROM table GROUP BY do WITH ROLLUP";
[code=php]
The last record will be a NULL date and the total ips from all dates. Of course any ip that features in multiple dates will be counted multiple times.
Finally, if you just want the total unique ips regardless of date then
[code=php]
[code=php]
$sql = "SELECT COUNT(ip) FROM table GROUP BY ip";
[code=php]